Move renaming and adding into rendered-target with tests

This commit is contained in:
Paul Kaplan committed 2017-07-25 10:32:25 -04:00
1 parent ef16a7d574
commit f96a92b4d1
4 files changed
+89 -48

No files matched your search

+40
View File
@@ -355,3 +355,43 @@ test('#toJSON returns the sounds and costumes', t => {
t.same(a.toJSON().costumes, costumes);
t.end();
});
test('#addSound does not duplicate names', t => {
const spr = new Sprite();
const a = new RenderedTarget(spr, null);
a.sprite.sounds = [{name: 'first'}];
a.addSound({name: 'first'});
t.deepEqual(a.sprite.sounds, [{name: 'first'}, {name: 'first2'}]);
t.end();
});
test('#addCostume does not duplicate names', t => {
const spr = new Sprite();
const a = new RenderedTarget(spr, null);
a.sprite.costumes = [{name: 'first'}];
a.addCostume({name: 'first'});
t.deepEqual(a.sprite.costumes, [{name: 'first'}, {name: 'first2'}]);
t.end();
});
test('#renameSound does not duplicate names', t => {
const spr = new Sprite();
const a = new RenderedTarget(spr, null);
a.sprite.sounds = [{name: 'first'}, {name: 'second'}];
a.renameSound(0, 'first'); // Shouldn't increment the name, noop
t.deepEqual(a.sprite.sounds, [{name: 'first'}, {name: 'second'}]);
a.renameSound(1, 'first');
t.deepEqual(a.sprite.sounds, [{name: 'first'}, {name: 'first2'}]);
t.end();
});
test('#renameCostume does not duplicate names', t => {
const spr = new Sprite();
const a = new RenderedTarget(spr, null);
a.sprite.costumes = [{name: 'first'}, {name: 'second'}];
a.renameCostume(0, 'first'); // Shouldn't increment the name, noop
t.deepEqual(a.sprite.costumes, [{name: 'first'}, {name: 'second'}]);
a.renameCostume(1, 'first');
t.deepEqual(a.sprite.costumes, [{name: 'first'}, {name: 'first2'}]);
t.end();
});
-38
View File
@@ -109,41 +109,3 @@ test('renameSprite does not increment when renaming to the same name', t => {
t.equal(vm.runtime.targets[0].sprite.name, 'this name');
t.end();
});
test('renameSound sets the sound name', t => {
const vm = new VirtualMachine();
vm.editingTarget = {
sprite: {
sounds: [{name: 'first'}, {name: 'second'}]
}
};
vm.renameSound(0, 'hello');
t.equal(vm.editingTarget.sprite.sounds[0].name, 'hello');
t.equal(vm.editingTarget.sprite.sounds[1].name, 'second');
// Make sure renaming to same name doesn't increment
vm.renameSound(0, 'hello');
t.equal(vm.editingTarget.sprite.sounds[0].name, 'hello');
// But renaming to used name does increment
vm.renameSound(1, 'hello');
t.equal(vm.editingTarget.sprite.sounds[1].name, 'hello2');
t.end();
});
test('renameCostume sets the costume name', t => {
const vm = new VirtualMachine();
vm.editingTarget = {
sprite: {
costumes: [{name: 'first'}, {name: 'second'}]
}
};
vm.renameCostume(0, 'hello');
t.equal(vm.editingTarget.sprite.costumes[0].name, 'hello');
t.equal(vm.editingTarget.sprite.costumes[1].name, 'second');
// Make sure renaming to same name doesn't increment
vm.renameCostume(0, 'hello');
t.equal(vm.editingTarget.sprite.costumes[0].name, 'hello');
// But renaming to used name does increment
vm.renameCostume(1, 'hello');
t.equal(vm.editingTarget.sprite.costumes[1].name, 'hello2');
t.end();
});