mirror of
https://github.com/scratchfoundation/scratch-analysis.git
synced 2024-11-21 10:48:15 -05:00
Add test for incorrect costumes attribute in sb2 project
This commit is contained in:
parent
d2145d88c8
commit
10d1b914f5
2 changed files with 45 additions and 0 deletions
23
test/fixtures/sb2/invalid-costumes.json
vendored
Normal file
23
test/fixtures/sb2/invalid-costumes.json
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"objName": "Stage",
|
||||
"sounds": [{
|
||||
"soundName": "pop",
|
||||
"soundID": -1,
|
||||
"md5": "83a9787d4cb6f3b7632b4ddfebf74367.wav",
|
||||
"sampleCount": 258,
|
||||
"rate": 11025,
|
||||
"format": ""
|
||||
}],
|
||||
"costumes": {
|
||||
"invalid": "This should be an array but is an object instead"
|
||||
},
|
||||
"currentCostumeIndex": 0,
|
||||
"penLayerMD5": "5c81a336fab8be57adc039a8a2b33ca9.png",
|
||||
"penLayerID": -1,
|
||||
"children": [],
|
||||
"info": {
|
||||
"videoOn": false,
|
||||
"scriptCount": 0,
|
||||
"spriteCount": 0
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const test = require('tap').test;
|
||||
const analysis = require('../../lib/index');
|
||||
// using the sb2 directly to bypass scratch-parser and excersise
|
||||
// logic targeting broken project files
|
||||
const sb2 = require('../../lib/sb2');
|
||||
|
||||
const defaultObject = fs.readFileSync(
|
||||
path.resolve(__dirname, '../fixtures/sb2/default.json')
|
||||
|
@ -13,6 +16,10 @@ const complexBinary = fs.readFileSync(
|
|||
path.resolve(__dirname, '../fixtures/sb2/complex.sb2')
|
||||
);
|
||||
|
||||
const invalidCostumes = fs.readFileSync(
|
||||
path.resolve(__dirname, '../fixtures/sb2/invalid-costumes.json')
|
||||
);
|
||||
|
||||
test('default (object)', t => {
|
||||
analysis(defaultObject, (err, result) => {
|
||||
t.ok(typeof err === 'undefined' || err === null);
|
||||
|
@ -284,3 +291,18 @@ test('complex (binary)', t => {
|
|||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('stage with invalid costumes', t => {
|
||||
const project = JSON.parse(invalidCostumes);
|
||||
|
||||
sb2(project, (err, result) => {
|
||||
t.ok(typeof err === 'undefined' || err === null);
|
||||
t.type(result, 'object');
|
||||
t.type(result.backdrops, 'object');
|
||||
t.equal(result.backdrops.count, 0);
|
||||
t.same(result.backdrops.id, []);
|
||||
t.same(result.backdrops.hash, []);
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue