mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 20:14:00 -04:00
Add unit tests for new reporter blocks in looks
This commit is contained in:
parent
63be5bc487
commit
3afe709cb0
1 changed files with 52 additions and 0 deletions
52
test/unit/blocks_looks.js
Normal file
52
test/unit/blocks_looks.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const test = require('tap').test;
|
||||||
|
const Looks = require('../../src/blocks/scratch3_looks');
|
||||||
|
const util = {
|
||||||
|
target: {
|
||||||
|
currentCostume: 0, // Internally, current costume is 0 indexed
|
||||||
|
sprite: {
|
||||||
|
costumes: [
|
||||||
|
{name: 'first name'},
|
||||||
|
{name: 'second name'},
|
||||||
|
{name: 'third name'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fakeRuntime = {
|
||||||
|
getTargetForStage: () => util.target, // Just return the dummy target above.
|
||||||
|
on: () => {} // Stub out listener methods used in constructor.
|
||||||
|
};
|
||||||
|
const blocks = new Looks(fakeRuntime);
|
||||||
|
|
||||||
|
test('getCostumeNumberName returns 1-indexed costume number', t => {
|
||||||
|
util.target.currentCostume = 0; // This is 0-indexed.
|
||||||
|
const args = {NUMBER_NAME: 'number'};
|
||||||
|
const number = blocks.getCostumeNumberName(args, util);
|
||||||
|
t.strictEqual(number, 1);
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getCostumeNumberName can return costume name', t => {
|
||||||
|
util.target.currentCostume = 0; // This is 0-indexed.
|
||||||
|
const args = {NUMBER_NAME: 'name'};
|
||||||
|
const number = blocks.getCostumeNumberName(args, util);
|
||||||
|
t.strictEqual(number, 'first name');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBackdropNumberName returns 1-indexed costume number', t => {
|
||||||
|
util.target.currentCostume = 2; // This is 0-indexed.
|
||||||
|
const args = {NUMBER_NAME: 'number'};
|
||||||
|
const number = blocks.getBackdropNumberName(args, util);
|
||||||
|
t.strictEqual(number, 3);
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBackdropNumberName can return costume name', t => {
|
||||||
|
util.target.currentCostume = 2; // This is 0-indexed.
|
||||||
|
const args = {NUMBER_NAME: 'name'};
|
||||||
|
const number = blocks.getBackdropNumberName(args, util);
|
||||||
|
t.strictEqual(number, 'third name');
|
||||||
|
t.end();
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue