mirror of
https://github.com/google/blockly.git
synced 2026-01-15 04:47:10 +01:00
Update test asserts on stubs to use sinon asserts (#4205)
* Update asserts for stubs to use sinon asserts. * Manual update of unclear stub assert.
This commit is contained in:
@@ -33,7 +33,7 @@ suite('Dropdown Fields', function() {
|
||||
chai.assert.throws(function() {
|
||||
new Blockly.FieldDropdown([1, 2, 3]);
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Array Items with Invalid IDs', function() {
|
||||
@@ -41,7 +41,7 @@ suite('Dropdown Fields', function() {
|
||||
chai.assert.throws(function() {
|
||||
new Blockly.FieldDropdown([['1', 1], ['2', 2], ['3', 3]]);
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Array Items with Invalid Content', function() {
|
||||
@@ -49,7 +49,7 @@ suite('Dropdown Fields', function() {
|
||||
chai.assert.throws(function() {
|
||||
new Blockly.FieldDropdown([[1, '1'], [2, '2'], [3, '3']]);
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Text Dropdown', function() {
|
||||
@@ -99,7 +99,7 @@ suite('Dropdown Fields', function() {
|
||||
chai.assert.throws(function() {
|
||||
Blockly.FieldDropdown.fromJson({ options: [1, 2, 3] });
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Array Items with Invalid IDs', function() {
|
||||
@@ -108,7 +108,7 @@ suite('Dropdown Fields', function() {
|
||||
Blockly.FieldDropdown.fromJson(
|
||||
{ options:[['1', 1], ['2', 2], ['3', 3]] });
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Array Items with Invalid Content', function() {
|
||||
@@ -117,7 +117,7 @@ suite('Dropdown Fields', function() {
|
||||
Blockly.FieldDropdown.fromJson(
|
||||
{ options:[[1, '1'], [2, '2'], [3, '3']] });
|
||||
});
|
||||
chai.assert(stub.calledThrice);
|
||||
sinon.assert.calledThrice(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('Text Dropdown', function() {
|
||||
|
||||
@@ -125,7 +125,7 @@ suite('Variable Fields', function() {
|
||||
var stub = sinon.stub(console, 'warn');
|
||||
variableField.setValue(undefined);
|
||||
assertValue(variableField, 'name1');
|
||||
chai.assert(stub.calledOnce);
|
||||
sinon.assert.calledOnce(stub);
|
||||
stub.restore();
|
||||
});
|
||||
test('New Variable ID', function() {
|
||||
@@ -147,7 +147,7 @@ suite('Variable Fields', function() {
|
||||
var stub = sinon.stub(console, 'warn');
|
||||
variableField.setValue('id1');
|
||||
assertValue(variableField, 'name1');
|
||||
chai.assert(stub.calledOnce);
|
||||
sinon.assert.calledOnce(stub);
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -145,11 +145,11 @@ suite('Inputs', function() {
|
||||
var initSpy = sinon.spy(field, 'init');
|
||||
|
||||
this.dummy.insertFieldAt(0, field);
|
||||
chai.assert(setBlockSpy.calledOnce);
|
||||
sinon.assert.calledOnce(setBlockSpy);
|
||||
chai.assert.equal(setBlockSpy.getCall(0).args[0], this.block);
|
||||
chai.assert(initSpy.calledOnce);
|
||||
chai.assert(this.renderStub.calledOnce);
|
||||
chai.assert(this.bumpNeighboursStub.calledOnce);
|
||||
sinon.assert.calledOnce(initSpy);
|
||||
sinon.assert.calledOnce(this.renderStub);
|
||||
sinon.assert.calledOnce(this.bumpNeighboursStub);
|
||||
|
||||
setBlockSpy.restore();
|
||||
initSpy.restore();
|
||||
@@ -164,11 +164,11 @@ suite('Inputs', function() {
|
||||
this.block.rendered = false;
|
||||
|
||||
this.dummy.insertFieldAt(0, field);
|
||||
chai.assert(setBlockSpy.calledOnce);
|
||||
sinon.assert.calledOnce(setBlockSpy);
|
||||
chai.assert.equal(setBlockSpy.getCall(0).args[0], this.block);
|
||||
chai.assert(initModelSpy.calledOnce);
|
||||
chai.assert(this.renderStub.notCalled);
|
||||
chai.assert(this.bumpNeighboursStub.notCalled);
|
||||
sinon.assert.calledOnce(initModelSpy);
|
||||
sinon.assert.notCalled(this.renderStub);
|
||||
sinon.assert.notCalled(this.bumpNeighboursStub);
|
||||
|
||||
setBlockSpy.restore();
|
||||
initModelSpy.restore();
|
||||
@@ -190,9 +190,9 @@ suite('Inputs', function() {
|
||||
this.bumpNeighboursStub.resetHistory();
|
||||
|
||||
this.dummy.removeField('FIELD');
|
||||
chai.assert(disposeSpy.calledOnce);
|
||||
chai.assert(this.renderStub.calledOnce);
|
||||
chai.assert(this.bumpNeighboursStub.calledOnce);
|
||||
sinon.assert.calledOnce(disposeSpy);
|
||||
sinon.assert.calledOnce(this.renderStub);
|
||||
sinon.assert.calledOnce(this.bumpNeighboursStub);
|
||||
});
|
||||
test('Headless', function() {
|
||||
var field = new Blockly.FieldLabel('field');
|
||||
@@ -205,9 +205,9 @@ suite('Inputs', function() {
|
||||
this.block.rendered = false;
|
||||
|
||||
this.dummy.removeField('FIELD');
|
||||
chai.assert(disposeSpy.calledOnce);
|
||||
chai.assert(this.renderStub.notCalled);
|
||||
chai.assert(this.bumpNeighboursStub.notCalled);
|
||||
sinon.assert.calledOnce(disposeSpy);
|
||||
sinon.assert.notCalled(this.renderStub);
|
||||
sinon.assert.notCalled(this.bumpNeighboursStub);
|
||||
});
|
||||
});
|
||||
suite('Field Ordering/Manipulation', function() {
|
||||
|
||||
@@ -272,7 +272,7 @@ suite('Navigation', function() {
|
||||
sinon.spy(this.workspace.getCursor(), 'prev');
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.W;
|
||||
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
|
||||
chai.assert.isTrue(this.workspace.getCursor().prev.calledOnce);
|
||||
sinon.assert.calledOnce(this.workspace.getCursor().prev);
|
||||
chai.assert.equal(Blockly.navigation.currentState_,
|
||||
Blockly.navigation.STATE_WS);
|
||||
this.workspace.getCursor().prev.restore();
|
||||
@@ -283,7 +283,7 @@ suite('Navigation', function() {
|
||||
sinon.spy(cursor, 'next');
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.S;
|
||||
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
|
||||
chai.assert.isTrue(cursor.next.calledOnce);
|
||||
sinon.assert.calledOnce(cursor.next);
|
||||
chai.assert.equal(Blockly.navigation.currentState_,
|
||||
Blockly.navigation.STATE_WS);
|
||||
cursor.next.restore();
|
||||
@@ -294,7 +294,7 @@ suite('Navigation', function() {
|
||||
sinon.spy(cursor, 'out');
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.A;
|
||||
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
|
||||
chai.assert.isTrue(cursor.out.calledOnce);
|
||||
sinon.assert.calledOnce(cursor.out);
|
||||
chai.assert.equal(Blockly.navigation.currentState_,
|
||||
Blockly.navigation.STATE_WS);
|
||||
cursor.out.restore();
|
||||
@@ -305,7 +305,7 @@ suite('Navigation', function() {
|
||||
sinon.spy(cursor, 'in');
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.D;
|
||||
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
|
||||
chai.assert.isTrue(cursor.in.calledOnce);
|
||||
sinon.assert.calledOnce(cursor.in);
|
||||
chai.assert.equal(Blockly.navigation.currentState_,
|
||||
Blockly.navigation.STATE_WS);
|
||||
cursor.in.restore();
|
||||
@@ -315,7 +315,7 @@ suite('Navigation', function() {
|
||||
sinon.spy(Blockly.navigation, 'modify_');
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.I;
|
||||
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
|
||||
chai.assert.isTrue(Blockly.navigation.modify_.calledOnce);
|
||||
sinon.assert.calledOnce(Blockly.navigation.modify_);
|
||||
chai.assert.equal(Blockly.navigation.currentState_,
|
||||
Blockly.navigation.STATE_WS);
|
||||
Blockly.navigation.modify_.restore();
|
||||
@@ -386,7 +386,7 @@ suite('Navigation', function() {
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.N;
|
||||
var isHandled = Blockly.navigation.onKeyPress(this.mockEvent);
|
||||
chai.assert.isFalse(isHandled);
|
||||
chai.assert.isFalse(field.onBlocklyAction.calledOnce);
|
||||
sinon.assert.notCalled(field.onBlocklyAction);
|
||||
|
||||
field.onBlocklyAction.restore();
|
||||
});
|
||||
@@ -400,7 +400,7 @@ suite('Navigation', function() {
|
||||
|
||||
var isHandled = Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_OUT);
|
||||
chai.assert.isTrue(isHandled);
|
||||
chai.assert.isTrue(field.onBlocklyAction.calledOnce);
|
||||
sinon.assert.calledOnce(field.onBlocklyAction);
|
||||
|
||||
field.onBlocklyAction.restore();
|
||||
});
|
||||
@@ -414,7 +414,7 @@ suite('Navigation', function() {
|
||||
this.mockEvent.keyCode = Blockly.utils.KeyCodes.A;
|
||||
var isHandled = Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_OUT);
|
||||
chai.assert.isTrue(isHandled);
|
||||
chai.assert.isTrue(field.onBlocklyAction.calledOnce);
|
||||
sinon.assert.calledOnce(field.onBlocklyAction);
|
||||
|
||||
field.onBlocklyAction.restore();
|
||||
});
|
||||
@@ -426,7 +426,7 @@ suite('Navigation', function() {
|
||||
|
||||
var isHandled = Blockly.navigation.onKeyPress(this.mockEvent);
|
||||
chai.assert.isTrue(isHandled);
|
||||
chai.assert.isTrue(Blockly.navigation.onBlocklyAction.calledOnce);
|
||||
sinon.assert.calledOnce(Blockly.navigation.onBlocklyAction);
|
||||
chai.assert.isFalse(Blockly.getMainWorkspace().keyboardAccessibilityMode);
|
||||
Blockly.navigation.onBlocklyAction.restore();
|
||||
});
|
||||
@@ -438,7 +438,7 @@ suite('Navigation', function() {
|
||||
|
||||
var isHandled = Blockly.navigation.onKeyPress(this.mockEvent);
|
||||
chai.assert.isTrue(isHandled);
|
||||
chai.assert.isTrue(Blockly.navigation.focusWorkspace_.calledOnce);
|
||||
sinon.assert.calledOnce(Blockly.navigation.focusWorkspace_);
|
||||
chai.assert.isTrue(Blockly.getMainWorkspace().keyboardAccessibilityMode);
|
||||
Blockly.navigation.focusWorkspace_.restore();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user