Cleanup of chai asserts (#4100)

This commit is contained in:
Monica Kozbial
2020-08-05 16:03:06 -07:00
committed by GitHub
parent 2e92123314
commit b69f59eae7
3 changed files with 36 additions and 36 deletions

View File

@@ -461,7 +461,7 @@ suite('Events', function() {
new Blockly.Events.Ui(block, 'click', undefined, undefined)
];
var filteredEvents = Blockly.Events.filter(events, true);
chai.assert.equal(4, filteredEvents.length); // no event should have been removed.
chai.assert.equal(filteredEvents.length, 4); // no event should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove);
@@ -479,7 +479,7 @@ suite('Events', function() {
new Blockly.Events.BlockMove(block2)
];
var filteredEvents = Blockly.Events.filter(events, true);
chai.assert.equal(4, filteredEvents.length); // no event should have been removed.
chai.assert.equal(filteredEvents.length, 4); // no event should have been removed.
});
test('Forward', function() {
@@ -489,12 +489,12 @@ suite('Events', function() {
addMoveEvent(events, block, 2, 2);
addMoveEvent(events, block, 3, 3);
var filteredEvents = Blockly.Events.filter(events, true);
chai.assert.equal(2, filteredEvents.length); // duplicate moves should have been removed.
chai.assert.equal(filteredEvents.length, 2); // duplicate moves should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove);
chai.assert.equal(3, filteredEvents[1].newCoordinate.x);
chai.assert.equal(3, filteredEvents[1].newCoordinate.y);
chai.assert.equal(filteredEvents[1].newCoordinate.x, 3);
chai.assert.equal(filteredEvents[1].newCoordinate.y, 3);
});
test('Backward', function() {
@@ -504,12 +504,12 @@ suite('Events', function() {
addMoveEvent(events, block, 2, 2);
addMoveEvent(events, block, 3, 3);
var filteredEvents = Blockly.Events.filter(events, false);
chai.assert.equal(2, filteredEvents.length); // duplicate event should have been removed.
chai.assert.equal(filteredEvents.length, 2); // duplicate event should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove);
chai.assert.equal(1, filteredEvents[1].newCoordinate.x);
chai.assert.equal(1, filteredEvents[1].newCoordinate.y);
chai.assert.equal(filteredEvents[1].newCoordinate.x, 1);
chai.assert.equal(filteredEvents[1].newCoordinate.y, 1);
});
test('Merge move events', function() {
@@ -518,9 +518,9 @@ suite('Events', function() {
addMoveEvent(events, block, 0, 0);
addMoveEvent(events, block, 1, 1);
var filteredEvents = Blockly.Events.filter(events, true);
chai.assert.equal(1, filteredEvents.length); // second move event merged into first
chai.assert.equal(1, filteredEvents[0].newCoordinate.x);
chai.assert.equal(1, filteredEvents[0].newCoordinate.y);
chai.assert.equal(filteredEvents.length, 1); // second move event merged into first
chai.assert.equal(filteredEvents[0].newCoordinate.x, 1);
chai.assert.equal(filteredEvents[0].newCoordinate.y, 1);
});
test('Merge change events', function() {
@@ -530,7 +530,7 @@ suite('Events', function() {
new Blockly.Events.Change(block1, 'field', 'VAR', 'item1', 'item2')
];
var filteredEvents = Blockly.Events.filter(events, true);
chai.assert.equal(1, filteredEvents.length); // second change event merged into first
chai.assert.equal(filteredEvents.length, 1); // second change event merged into first
chai.assert.equal(filteredEvents[0].oldValue, 'item');
chai.assert.equal(filteredEvents[0].newValue, 'item2');
});
@@ -565,7 +565,7 @@ suite('Events', function() {
];
var filteredEvents = Blockly.Events.filter(events, true);
// click and stackclick should both exist
chai.assert.equal(2, filteredEvents.length);
chai.assert.equal(filteredEvents.length, 2);
chai.assert.equal(filteredEvents[0].element, 'click');
chai.assert.equal(filteredEvents[1].element, 'stackclick');
});
@@ -586,7 +586,7 @@ suite('Events', function() {
var filteredEvents = Blockly.Events.filter(events, true);
// The two events should be merged, but because nothing has changed
// they will be filtered out.
chai.assert.equal(0, filteredEvents.length);
chai.assert.equal(filteredEvents.length, 0);
});
test('Move events different blocks not merged', function() {
@@ -606,7 +606,7 @@ suite('Events', function() {
var filteredEvents = Blockly.Events.filter(events, true);
// Nothing should have merged.
chai.assert.equal(4, filteredEvents.length);
chai.assert.equal(filteredEvents.length, 4);
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockMove);
chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove);

View File

@@ -144,8 +144,8 @@ suite('JSON Block Definitions', function() {
}]);
var block = new Blockly.Block(this.workspace_, BLOCK_TYPE);
chai.assert.equal(1, block.inputList.length);
chai.assert.equal(1, block.inputList[0].fieldRow.length);
chai.assert.equal(block.inputList.length, 1);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var textField = block.inputList[0].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE0, textField.getText());
@@ -165,14 +165,14 @@ suite('JSON Block Definitions', function() {
var block = new Blockly.Block(this.workspace_, BLOCK_TYPE);
this.blocks_.push(block);
chai.assert.equal(2, block.inputList.length);
chai.assert.equal(block.inputList.length, 2);
chai.assert.equal(1, block.inputList[0].fieldRow.length);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var textField = block.inputList[0].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE0, textField.getText());
chai.assert.equal(1, block.inputList[1].fieldRow.length);
chai.assert.equal(block.inputList[1].fieldRow.length, 1);
var textField = block.inputList[1].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE1, textField.getText());
@@ -193,8 +193,8 @@ suite('JSON Block Definitions', function() {
var block = new Blockly.Block(this.workspace_, BLOCK_TYPE);
this.blocks_.push(block);
chai.assert.equal(1, block.inputList.length);
chai.assert.equal(1, block.inputList[0].fieldRow.length);
chai.assert.equal(block.inputList.length, 1);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var textField = block.inputList[0].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE, textField.getText());
@@ -225,8 +225,8 @@ suite('JSON Block Definitions', function() {
var block = new Blockly.Block(this.workspace_, BLOCK_TYPE);
this.blocks_.push(block);
chai.assert.equal(1, block.inputList.length);
chai.assert.equal(1, block.inputList[0].fieldRow.length);
chai.assert.equal(block.inputList.length, 1);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var dropdown = block.inputList[0].fieldRow[0];
chai.assert.equal(dropdown, block.getField(FIELD_NAME));
chai.assert.equal(Blockly.FieldDropdown, dropdown.constructor);
@@ -286,8 +286,8 @@ suite('JSON Block Definitions', function() {
var block = new Blockly.Block(this.workspace_, BLOCK_TYPE);
this.blocks_.push(block);
chai.assert.equal(1, block.inputList.length);
chai.assert.equal(1, block.inputList[0].fieldRow.length);
chai.assert.equal(block.inputList.length, 1);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var dropdown = block.inputList[0].fieldRow[0];
chai.assert.equal(dropdown, block.getField(FIELD_NAME));
chai.assert.equal(Blockly.FieldDropdown, dropdown.constructor);

View File

@@ -249,8 +249,8 @@ suite('Insert/Modify', function() {
this.row_block_1));
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.row_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
chai.assert.equal(pos.x, 100);
chai.assert.equal(pos.y, 200);
});
test('Cursor on output connection', function() {
@@ -259,8 +259,8 @@ suite('Insert/Modify', function() {
this.row_block_1.outputConnection));
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.row_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
chai.assert.equal(pos.x, 100);
chai.assert.equal(pos.y, 200);
});
test('Cursor on previous connection', function() {
@@ -269,8 +269,8 @@ suite('Insert/Modify', function() {
this.stack_block_1.previousConnection));
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.stack_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
chai.assert.equal(pos.x, 100);
chai.assert.equal(pos.y, 200);
});
test('Cursor on input connection', function() {
@@ -300,8 +300,8 @@ suite('Insert/Modify', function() {
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.isNull(this.row_block_2.getParent());
var pos = this.row_block_2.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
chai.assert.equal(pos.x, 100);
chai.assert.equal(pos.y, 200);
});
test('Cursor on child block (stack)', function() {
@@ -315,8 +315,8 @@ suite('Insert/Modify', function() {
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_2.getParent());
var pos = this.stack_block_2.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
chai.assert.equal(pos.x, 100);
chai.assert.equal(pos.y, 200);
});
test('Cursor on workspace', function() {