mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Add test for skipping rename on blank input
This commit is contained in:
parent
627fc1d9c3
commit
5d2352e471
2 changed files with 15 additions and 1 deletions
|
@ -204,7 +204,9 @@ VirtualMachine.prototype.renameSprite = function (targetId, newName) {
|
|||
if (!sprite) {
|
||||
throw new Error('No sprite associated with this target.');
|
||||
}
|
||||
sprite.name = newName;
|
||||
if (newName) {
|
||||
sprite.name = newName;
|
||||
}
|
||||
this.emitTargetsUpdate();
|
||||
} else {
|
||||
throw new Error('No target with the provided id.');
|
||||
|
|
|
@ -49,3 +49,15 @@ test('renameSprite sets the sprite name', function (t) {
|
|||
t.equal(fakeTarget.sprite.name, 'not-original');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('renameSprite does not set sprite names to an empty string ', function (t) {
|
||||
var vm = new VirtualMachine();
|
||||
var fakeTarget = {
|
||||
sprite: {name: 'original'},
|
||||
isSprite: () => true
|
||||
};
|
||||
vm.runtime.getTargetById = () => (fakeTarget);
|
||||
vm.renameSprite('id', '');
|
||||
t.equal(fakeTarget.sprite.name, 'original');
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue