p8-data-cart
Version:
Simple tools for generating Pico-8 data carts.
45 lines (44 loc) • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("chai/register-should.js");
const fs_1 = require("fs");
const cart_parser_js_1 = require("../cart-parser.js");
const should = require('chai').should();
describe('cart-parser', function () {
let cartData;
before(function () {
const cartString = (0, fs_1.readFileSync)('test_data/test_cart.p8', 'utf-8');
cartData = (0, cart_parser_js_1.parseCart)(cartString);
});
it('should parse the version number', function () {
cartData.version.should.equal(1337);
});
it('should parse the lua section', function () {
cartData.lua.should.be.a('string');
cartData.lua.should.include('print("this is a test")');
cartData.lua.should.include('this concludes the test');
});
it('should parse the gfx section', function () {
cartData.gfx.slice(0, 256).every(byte => byte == 0xab).should.be.true;
cartData.gfx.slice(256).every(byte => byte == 0x00).should.be.true;
});
it('should parse the label section', function () {
cartData.label.every((byte, i) => byte == (i % 2 == 0 ? 0xa : 0x8c)).should.be.true;
});
it('should parse the gff section', function () {
cartData.gff.slice(0, 256).every(byte => byte == 0xad).should.be.true;
cartData.gff.slice(256).every(byte => byte == 0x00).should.be.true;
});
it('should parse the map section', function () {
cartData.map.slice(0, 256).every(byte => byte == 0x01).should.be.true;
cartData.map.slice(256).every(byte => byte == 0x00).should.be.true;
});
it('should parse the sfx section', function () {
cartData.sfx.slice(0, 272).every(byte => byte == 0xaf).should.be.true;
cartData.sfx.slice(272).every(byte => byte == 0x00).should.be.true;
});
it('should parse the music section', function () {
cartData.music.slice(0, 256).every(byte => byte == 0xae).should.be.true;
cartData.music.slice(256).every(byte => byte == 0x00).should.be.true;
});
});