mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Adding async cleanup to tests (#4103)
* Adding setup and teardown to more mocha tests. * Update workspace dispose cleanup calls.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('ASTNode', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "input_statement",
|
||||
"message0": "%1 %2 %3 %4",
|
||||
@@ -90,12 +91,10 @@ suite('ASTNode', function() {
|
||||
sinon.stub(Blockly, "getMainWorkspace").returns(new Blockly.Workspace());
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['input_statement'];
|
||||
delete Blockly.Blocks['field_input'];
|
||||
delete Blockly.Blocks['value_input'];
|
||||
|
||||
this.workspace.dispose();
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
suite('HelperFunctions', function() {
|
||||
|
||||
@@ -1077,7 +1077,7 @@ suite('Blocks', function() {
|
||||
), this.workspace);
|
||||
});
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
});
|
||||
test('Text', function() {
|
||||
this.block.setCommentText('test text');
|
||||
@@ -1139,11 +1139,11 @@ suite('Blocks', function() {
|
||||
suite('Icon Management', function() {
|
||||
suite('Bubbles and Collapsing', function() {
|
||||
setup(function() {
|
||||
this.workspace.dispose();
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
this.workspace = Blockly.inject('blocklyDiv');
|
||||
});
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
});
|
||||
|
||||
test('Has Icon', function() {
|
||||
@@ -1653,7 +1653,7 @@ suite('Blocks', function() {
|
||||
}), {});
|
||||
});
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
// Clear all registered themes.
|
||||
Blockly.registry.typeMap_['theme'] = {};
|
||||
});
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Connection checker', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
suiteSetup(function() {
|
||||
this.checker = new Blockly.ConnectionChecker();
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Connection Database', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.database = new Blockly.ConnectionDB(new Blockly.ConnectionChecker());
|
||||
|
||||
this.assertOrder = function() {
|
||||
@@ -33,6 +34,9 @@ suite('Connection Database', function() {
|
||||
}
|
||||
};
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
test('Add Connection', function() {
|
||||
var y2 = {y: 2};
|
||||
var y4 = {y: 4};
|
||||
@@ -193,22 +197,21 @@ suite('Connection Database', function() {
|
||||
|
||||
suite('Search For Closest', function() {
|
||||
setup(function() {
|
||||
this.allowedStubs = [];
|
||||
// Ignore type checks.
|
||||
this.allowedStubs.push(sinon.stub(this.database.connectionChecker_, 'doTypeChecks')
|
||||
sinon.stub(this.database.connectionChecker_, 'doTypeChecks')
|
||||
.callsFake(function(_a, _b) {
|
||||
return true;
|
||||
}));
|
||||
});
|
||||
// Ignore safety checks.
|
||||
this.allowedStubs.push(sinon.stub(this.database.connectionChecker_, 'doSafetyChecks')
|
||||
sinon.stub(this.database.connectionChecker_, 'doSafetyChecks')
|
||||
.callsFake(function(_a, _b) {
|
||||
return Blockly.Connection.CAN_CONNECT;
|
||||
}));
|
||||
});
|
||||
// Skip everything but the distance checks.
|
||||
this.allowedStubs.push(sinon.stub(this.database.connectionChecker_, 'doDragChecks')
|
||||
sinon.stub(this.database.connectionChecker_, 'doDragChecks')
|
||||
.callsFake(function(a, b, distance) {
|
||||
return a.distanceFrom(b) <= distance;
|
||||
}));
|
||||
});
|
||||
|
||||
this.createCheckConnection = function(x, y) {
|
||||
var checkConnection = this.createConnection(x, y, Blockly.NEXT_STATEMENT,
|
||||
@@ -216,11 +219,6 @@ suite('Connection Database', function() {
|
||||
return checkConnection;
|
||||
};
|
||||
});
|
||||
teardown(function() {
|
||||
for (var i = 0; i < this.allowedStubs.length; i++) {
|
||||
this.allowedStubs[i].restore();
|
||||
}
|
||||
});
|
||||
test('Empty Database', function() {
|
||||
var checkConnection = this.createConnection(0, 0, Blockly.NEXT_STATEMENT,
|
||||
new Blockly.ConnectionDB());
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
*/
|
||||
|
||||
suite('Connection', function() {
|
||||
suiteSetup(function() {
|
||||
this.workspace = {
|
||||
connectionChecker: new Blockly.ConnectionChecker()
|
||||
};
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = sinon.createStubInstance(Blockly.Workspace);
|
||||
this.workspace.connectionChecker = new Blockly.ConnectionChecker();
|
||||
this.createConnection = function(type) {
|
||||
var block = {
|
||||
workspace: this.workspace,
|
||||
@@ -18,6 +18,9 @@ suite('Connection', function() {
|
||||
return connection;
|
||||
};
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
test('canConnectWithReason passes', function() {
|
||||
var conn1 = this.createConnection(Blockly.PREVIOUS_STATEMENT);
|
||||
var conn2 = this.createConnection(Blockly.NEXT_STATEMENT);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Cursor', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "input_statement",
|
||||
"message0": "%1 %2 %3 %4",
|
||||
@@ -72,10 +73,9 @@ suite('Cursor', function() {
|
||||
};
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['input_statement'];
|
||||
delete Blockly.Blocks['field_input'];
|
||||
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Next - From a Previous skip over next connection and block', function() {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
suite('DropDownDiv', function() {
|
||||
suite('Positioning', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.boundsStub = sinon.stub(Blockly.DropDownDiv, 'getBoundsInfo_')
|
||||
.returns({
|
||||
left: 0,
|
||||
@@ -27,10 +28,7 @@ suite('DropDownDiv', function() {
|
||||
.get(function() { return 0; });
|
||||
});
|
||||
teardown(function() {
|
||||
this.boundsStub.restore();
|
||||
this.sizeStub.restore();
|
||||
this.clientHeightStub.restore();
|
||||
this.clientTopStub.restore();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
test('Below, in Bounds', function() {
|
||||
var metrics = Blockly.DropDownDiv.getPositionMetrics_(50, 0, 50, -10);
|
||||
|
||||
@@ -6,25 +6,21 @@
|
||||
|
||||
suite('Extensions', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
this.blockTypesCleanup_ = [];
|
||||
this.extensionsCleanup_ = [];
|
||||
});
|
||||
teardown(function() {
|
||||
var i;
|
||||
for (i = 0; i < this.blockTypesCleanup_.length; i++) {
|
||||
sharedTestTeardown.call(this);
|
||||
for (let i = 0; i < this.blockTypesCleanup_.length; i++) {
|
||||
var blockType = this.blockTypesCleanup_[i];
|
||||
delete Blockly.Blocks[blockType];
|
||||
}
|
||||
for (i = 0; i < this.extensionsCleanup_.length; i++) {
|
||||
for (let i = 0; i < this.extensionsCleanup_.length; i++) {
|
||||
var extension = this.extensionsCleanup_[i];
|
||||
delete Blockly.Extensions.ALL_[extension];
|
||||
}
|
||||
this.workspace.dispose();
|
||||
// Clear Blockly.Event state.
|
||||
Blockly.Events.setGroup(false);
|
||||
Blockly.Events.disabled_ = 0;
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
test('Definition before and after block type', function() {
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Angle Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Checkbox Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Colour Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Dropdown Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
function assertValue(dropdownField, expectedValue, expectedText) {
|
||||
var actualValue = dropdownField.getValue();
|
||||
var actualText = dropdownField.getText();
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Image Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
function assertValue(imageField, expectedValue, expectedText) {
|
||||
var actualValue = imageField.getValue();
|
||||
var actualText = imageField.getText();
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Label Serializable Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Label Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Number Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -19,11 +19,16 @@ suite('Field Registry', function() {
|
||||
return new CustomFieldType(options['value']);
|
||||
};
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
if (Blockly.registry.typeMap_['field']['field_custom_test']) {
|
||||
delete Blockly.registry.typeMap_['field']['field_custom_test'];
|
||||
}
|
||||
});
|
||||
|
||||
suite('Registration', function() {
|
||||
test('Simple', function() {
|
||||
Blockly.fieldRegistry.register('field_custom_test', CustomFieldType);
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Abstract Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
suite('Is Serializable', function() {
|
||||
// Both EDITABLE and SERIALIZABLE are default.
|
||||
function FieldDefault() {
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('Text Input Fields', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
/**
|
||||
* Configuration for field tests with invalid values.
|
||||
* @type {!Array<!FieldCreationTestCase>}
|
||||
|
||||
@@ -44,14 +44,14 @@ suite('Variable Fields', function() {
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
createGenUidStubWithReturns(FAKE_ID);
|
||||
sinon.stub(Blockly.Variables, 'generateUniqueName')
|
||||
.returns(FAKE_VARIABLE_NAME);
|
||||
});
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sinon.restore();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Dropdown contains variables', function() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Flyout', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "basic_block",
|
||||
"message0": "%1",
|
||||
@@ -25,9 +26,8 @@ suite('Flyout', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
suite('createFlyoutInfo_', function() {
|
||||
|
||||
@@ -12,11 +12,12 @@ goog.require('Blockly.Python');
|
||||
|
||||
suite('Generator', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
suite('prefix', function() {
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
suite('Gesture', function() {
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
this.e = {};
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Constructor', function() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Inputs', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
"type": "empty_block",
|
||||
@@ -30,11 +31,8 @@ suite('Inputs', function() {
|
||||
this.bumpNeighboursStub.resetHistory();
|
||||
});
|
||||
teardown(function() {
|
||||
this.renderStub.restore();
|
||||
this.bumpNeighboursStub.restore();
|
||||
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['empty_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
suite('Insert Field At', function() {
|
||||
suite('Index Bounds', function() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('JSON Block Definitions', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace_ = new Blockly.Workspace();
|
||||
this.blocks_ = [];
|
||||
this.blockTypes_ = [];
|
||||
@@ -13,6 +14,7 @@ suite('JSON Block Definitions', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
for (var i = 0; i < this.blocks_.length; i++) {
|
||||
var block = this.blocks_[i];
|
||||
block.dispose();
|
||||
@@ -23,7 +25,6 @@ suite('JSON Block Definitions', function() {
|
||||
for (var i = 0, message; (message = this.messages_[i]); i++) {
|
||||
delete Blockly.Msg[message];
|
||||
}
|
||||
this.workspace_.dispose();
|
||||
});
|
||||
|
||||
suite('defineBlocksWithJsonArray', function() {
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
|
||||
suite('Key Map Tests', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.user.keyMap.setKeyMap(Blockly.user.keyMap.createDefaultKeyMap());
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Test adding a new action to key map', function() {
|
||||
var newAction = new Blockly.Action('test_action', 'test', function(){
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
suite('Logic ternary', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
this.block = this.workspace.newBlock('logic_ternary');
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Structure', function() {
|
||||
|
||||
@@ -34,6 +34,13 @@ suite('Metrics', function() {
|
||||
};
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('GetContentDimensionsExact - empty', function() {
|
||||
var ws = makeMockWs(1, 0, 0, 0, 0);
|
||||
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
'use strict';
|
||||
|
||||
suite('Names', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Safe name', function() {
|
||||
var varDB = new Blockly.Names('window,door');
|
||||
|
||||
@@ -22,6 +22,13 @@ suite('Navigation', function() {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
// Test that toolbox key handlers call through to the right functions and
|
||||
// transition correctly between toolbox, workspace, and flyout.
|
||||
suite('Tests toolbox keys', function() {
|
||||
@@ -50,8 +57,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Next', function() {
|
||||
@@ -166,8 +173,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
// Should be a no-op
|
||||
@@ -257,8 +264,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Previous', function() {
|
||||
@@ -368,8 +375,8 @@ suite('Navigation', function() {
|
||||
};
|
||||
});
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
test('Action does not exist', function() {
|
||||
var block = this.workspace.getTopBlocks()[0];
|
||||
@@ -481,8 +488,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['field_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Perform valid action for read only', function() {
|
||||
@@ -528,8 +535,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Insert from flyout with a valid connection marked', function() {
|
||||
@@ -633,9 +640,9 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['inline_block'];
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Connect cursor on previous into stack', function() {
|
||||
@@ -704,8 +711,8 @@ suite('Navigation', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Delete block - has parent ', function() {
|
||||
|
||||
@@ -16,7 +16,11 @@ suite('Registry', function() {
|
||||
return 'something';
|
||||
};
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
if (Blockly.registry.typeMap_['test'] &&
|
||||
Blockly.registry.typeMap_['test']['test_name']) {
|
||||
delete Blockly.registry.typeMap_['test']['test_name'];
|
||||
|
||||
@@ -74,7 +74,6 @@ function createEventsFireStubFireImmediately_(clock) {
|
||||
// stub.wrappedMethod.call(this, ...arguments);
|
||||
// // Advance clock forward to run any queued events.
|
||||
// clock.runAll();
|
||||
//
|
||||
if (!Blockly.Events.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Toolbox', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "basic_block",
|
||||
"message0": "%1",
|
||||
@@ -26,9 +27,8 @@ suite('Toolbox', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['basic_block'];
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
suite('init', function() {
|
||||
@@ -184,9 +184,9 @@ suite('Toolbox', function() {
|
||||
sinon.assert.calledOnce(flyoutHideStub);
|
||||
});
|
||||
test('UI Event is fired when new category is selected', function() {
|
||||
var eventsFireStub = sinon.stub(Blockly.Events, 'fire');
|
||||
this.eventsFireStub.resetHistory();
|
||||
this.toolbox.handleAfterTreeSelected_(this.firstChild);
|
||||
sinon.assert.calledOnce(eventsFireStub);
|
||||
sinon.assert.calledOnce(this.eventsFireStub);
|
||||
});
|
||||
test('Last category is updated when there is a new node', function() {
|
||||
this.toolbox.handleAfterTreeSelected_(this.firstChild, this.secondChild);
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
*/
|
||||
|
||||
suite('Utils', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('genUid', function() {
|
||||
var uuids = {};
|
||||
chai.assert.equal([1,2,3].indexOf(4), -1);
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
suite('Variable Map', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
this.variableMap = new Blockly.VariableMap(this.workspace);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sinon.restore();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
suite('createVariable', function() {
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
suite('Variable Model', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.workspace.dispose();
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
test('Trivial', function() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
suite('Variables', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
this.workspace = new Blockly.Workspace();
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "get_var_block",
|
||||
@@ -24,13 +25,8 @@ suite('Variables', function() {
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
delete Blockly.Blocks['get_var_block'];
|
||||
this.workspace.dispose();
|
||||
|
||||
// Clear Blockly.Event state.
|
||||
Blockly.Events.setGroup(false);
|
||||
Blockly.Events.disabled_ = 0;
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
suite('WidgetDiv', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
suite('positionWithAnchor', function() {
|
||||
function makeBBox(left, top, width, height) {
|
||||
|
||||
@@ -256,7 +256,7 @@ function testAWorkspace() {
|
||||
// Have to dispose of the main workspace after the flyout workspace
|
||||
// because it holds the variable map.
|
||||
// Normally the main workspace disposes of the flyout workspace.
|
||||
this.targetWorkspace.dispose();
|
||||
workspaceTeardown.call(this, this.targetWorkspace);
|
||||
});
|
||||
|
||||
test('Trivial Flyout is True', function() {
|
||||
|
||||
@@ -8,6 +8,13 @@ goog.require('Blockly.Blocks.procedures');
|
||||
goog.require('Blockly.Msg');
|
||||
|
||||
suite('Procedures XML', function() {
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
});
|
||||
teardown(function() {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
suite('Deserialization', function() {
|
||||
setup(function() {
|
||||
this.workspace = new Blockly.Workspace();
|
||||
|
||||
Reference in New Issue
Block a user