mirror of
https://github.com/scratchfoundation/scratch-analysis.git
synced 2024-11-28 10:35:34 -05:00
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const test = require('tap').test;
|
|
const analysis = require('../../lib/index');
|
|
|
|
const sb2 = fs.readFileSync(
|
|
path.resolve(__dirname, '../fixtures/sb2/cloud_opcodes.sb2')
|
|
);
|
|
const sb3 = fs.readFileSync(
|
|
path.resolve(__dirname, '../fixtures/sb3/cloud_opcodes.sb3')
|
|
);
|
|
|
|
test('sb2', t => {
|
|
analysis(sb2, (err, result) => {
|
|
t.true(typeof err === 'undefined' || err === null);
|
|
t.type(result, 'object');
|
|
t.type(result.blocks, 'object');
|
|
t.type(result.blocks.id, 'object');
|
|
t.deepEquals(result.blocks.id, [
|
|
'whenGreenFlag',
|
|
'doForever',
|
|
'setVar:to:',
|
|
'randomFrom:to:',
|
|
'changeVar:by:',
|
|
'setVar:to:',
|
|
'randomFrom:to:',
|
|
'changeVar:by:',
|
|
'setVar:to:cloud:',
|
|
'randomFrom:to:',
|
|
'changeVar:by:cloud:',
|
|
'wait:elapsed:from:'
|
|
]);
|
|
t.end();
|
|
});
|
|
});
|
|
|
|
test('sb3', t => {
|
|
analysis(sb3, (err, result) => {
|
|
t.true(typeof err === 'undefined' || err === null);
|
|
t.type(result, 'object');
|
|
t.type(result.blocks, 'object');
|
|
t.type(result.blocks.id, 'object');
|
|
t.deepEquals(result.blocks.id, [
|
|
'event_whenflagclicked',
|
|
'control_forever',
|
|
'control_wait',
|
|
'data_setvariableto',
|
|
'data_setvariableto',
|
|
'data_setvariableto_cloud',
|
|
'operator_random',
|
|
'operator_random',
|
|
'operator_random',
|
|
'data_changevariableby',
|
|
'data_changevariableby',
|
|
'data_changevariableby_cloud'
|
|
]);
|
|
t.end();
|
|
});
|
|
});
|