mirror of
https://github.com/google/blockly.git
synced 2026-01-16 13:27:09 +01:00
fix: change tests to use local helpers
This commit is contained in:
@@ -13,19 +13,19 @@ goog.addDependency('../../tests/mocha/cursor_test.js', ['Blockly.test.cursor'],
|
||||
goog.addDependency('../../tests/mocha/dropdowndiv_test.js', ['Blockly.test.dropdown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/event_test.js', ['Blockly.test.event'], ['Blockly.ASTNode', 'Blockly.Events.utils', 'Blockly.WorkspaceComment', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/extensions_test.js', ['Blockly.test.extensions'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_angle_test.js', ['Blockly.test.fieldAngle'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_checkbox_test.js', ['Blockly.test.fieldCheckbox'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_colour_test.js', ['Blockly.test.fieldColour'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_dropdown_test.js', ['Blockly.test.fieldDropdown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_image_test.js', ['Blockly.test.fieldImage'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_label_serializable_test.js', ['Blockly.test.fieldLabelSerialization'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_label_test.js', ['Blockly.test.fieldLabel'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_multilineinput_test.js', ['Blockly.test.fieldMultiline'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_number_test.js', ['Blockly.test.fieldNumber'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_angle_test.js', ['Blockly.test.fieldAngle'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_checkbox_test.js', ['Blockly.test.fieldCheckbox'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_colour_test.js', ['Blockly.test.fieldColour'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_dropdown_test.js', ['Blockly.test.fieldDropdown'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_image_test.js', ['Blockly.test.fieldImage'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_label_serializable_test.js', ['Blockly.test.fieldLabelSerialization'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_label_test.js', ['Blockly.test.fieldLabel'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_multilineinput_test.js', ['Blockly.test.fieldMultiline'], ['Blockly.test.blockHelpers', 'Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_number_test.js', ['Blockly.test.fieldNumber'], ['Blockly.test.commonHelpers', 'Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_registry_test.js', ['Blockly.test.fieldRegistry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_test.js', ['Blockly.test.fieldTest'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_textinput_test.js', ['Blockly.test.fieldTextInput'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_variable_test.js', ['Blockly.test.fieldVariable'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_textinput_test.js', ['Blockly.test.fieldTextInput'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/field_variable_test.js', ['Blockly.test.fieldVariable'], ['Blockly.test.fieldHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/flyout_test.js', ['Blockly.test.flyout'], ['Blockly.test.helpers', 'Blockly.test.toolboxHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/generator_test.js', ['Blockly.test.generator'], ['Blockly.Dart', 'Blockly.JavaScript', 'Blockly.Lua', 'Blockly.PHP', 'Blockly.Python', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/gesture_test.js', ['Blockly.test.gesture'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -35,20 +35,20 @@ goog.addDependency('../../tests/mocha/jso_deserialization_test.js', ['Blockly.te
|
||||
goog.addDependency('../../tests/mocha/jso_serialization_test.js', ['Blockly.test.jsoSerialization'], ['Blockly.test.helpers'], {'lang': 'es8', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/json_test.js', ['Blockly.test.json'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/keydown_test.js', ['Blockly.test.keydown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/logic_ternary_test.js', ['Blockly.test.logicTernary'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/logic_ternary_test.js', ['Blockly.test.logicTernary'], ['Blockly.Events.utils', 'Blockly.test.blockHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/metrics_test.js', ['Blockly.test.metrics'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/mutator_test.js', ['Blockly.test.mutator'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/names_test.js', ['Blockly.test.names'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/procedures_test.js', ['Blockly.test.procedures'], ['Blockly', 'Blockly.Msg', 'Blockly.test.helpers', 'Blockly.test.procedureHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/procedures_test.js', ['Blockly.test.procedures'], ['Blockly', 'Blockly.Msg', 'Blockly.test.blockHelpers', 'Blockly.test.helpers', 'Blockly.test.procedureHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/registry_test.js', ['Blockly.test.registry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/run_mocha_tests_in_browser.js', [], [], {'lang': 'es8'});
|
||||
goog.addDependency('../../tests/mocha/serializer_test.js', ['Blockly.test.serialization'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/serializer_test.js', ['Blockly.test.serialization'], ['Blockly.test.commonHelpers', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/shortcut_registry_test.js', ['Blockly.test.shortcutRegistry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/block_test_helpers.mocha.js', ['Blockly.test.blockHelpers'], ['Blockly.test.commonHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/common_test_helpers.mocha.js', ['Blockly.test.commonHelpers'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/field_test_helpers.mocha.js', ['Blockly.test.fieldHelpers'], ['Blockly.test.commonHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/procedures_test_helpers.js', ['Blockly.test.procedureHelpers'], ['Blockly.ConnectionType'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/test_helpers.js', ['Blockly.test.helpers'], ['Blockly.Events.utils', 'Blockly.blocks', 'Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/test_helpers.js', ['Blockly.test.helpers'], ['Blockly.Events.utils', 'Blockly.blocks', 'Blockly.test.commonHelpers', 'Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/test_helpers/toolbox_helper.js', ['Blockly.test.toolboxHelpers'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/theme_test.js', ['Blockly.test.theme'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/toolbox_test.js', ['Blockly.test.toolbox'], ['Blockly.test.helpers', 'Blockly.test.toolboxHelpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"globals": {
|
||||
"chai": false,
|
||||
"sinon": false,
|
||||
"testHelpers": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": ["off"],
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldAngle');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -60,7 +61,7 @@ suite('Angle Fields', function() {
|
||||
* @param {FieldTemplate} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue);
|
||||
assertFieldValue(field, defaultFieldValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -68,14 +69,14 @@ suite('Angle Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldAngle, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldAngle, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -84,12 +85,12 @@ suite('Angle Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldAngle();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue(2.5);
|
||||
testHelpers.assertFieldValue(this.field, 2.5);
|
||||
assertFieldValue(this.field, 2.5);
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -97,12 +98,12 @@ suite('Angle Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldAngle(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue(2.5);
|
||||
testHelpers.assertFieldValue(this.field, 2.5);
|
||||
assertFieldValue(this.field, 2.5);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -142,12 +143,12 @@ suite('Angle Fields', function() {
|
||||
this.field.isBeingEdited_ = true;
|
||||
this.field.htmlInput_.value = String(suiteInfo.value);
|
||||
this.field.onHtmlInputChange_(null);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
this.field, suiteInfo.expectedValue, String(suiteInfo.value));
|
||||
});
|
||||
test('When Not Editing', function() {
|
||||
this.field.setValue(suiteInfo.value);
|
||||
testHelpers.assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldCheckbox');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -61,7 +62,7 @@ suite('Checkbox Fields', function() {
|
||||
* @param {!Blockly.FieldCheckbox} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
field, defaultFieldValue, defaultFieldValue.toLowerCase());
|
||||
};
|
||||
/**
|
||||
@@ -70,15 +71,15 @@ suite('Checkbox Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
field, testCase.expectedValue, testCase.expectedValue.toLowerCase());
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldCheckbox, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldCheckbox, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -87,14 +88,14 @@ suite('Checkbox Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldCheckbox('TRUE');
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, 'TRUE', 'true');
|
||||
});
|
||||
suite('False -> New Value', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldCheckbox('FALSE');
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, 'FALSE', 'false');
|
||||
});
|
||||
});
|
||||
@@ -131,7 +132,7 @@ suite('Checkbox Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.field.setValue(suiteInfo.value);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
this.field, suiteInfo.expectedValue,
|
||||
String(suiteInfo.expectedValue).toLowerCase());
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldColour');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -87,7 +88,7 @@ suite('Colour Fields', function() {
|
||||
* @param {FieldTemplate} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue, defaultTextValue);
|
||||
assertFieldValue(field, defaultFieldValue, defaultTextValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -95,15 +96,15 @@ suite('Colour Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
field, testCase.expectedValue, testCase.expectedText);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldColour, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldColour, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -112,25 +113,25 @@ suite('Colour Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldColour();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue,
|
||||
defaultTextValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('#bcbcbc');
|
||||
testHelpers.assertFieldValue(this.field, '#bcbcbc', '#bcbcbc');
|
||||
assertFieldValue(this.field, '#bcbcbc', '#bcbcbc');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldColour('#aaaaaa');
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, '#aaaaaa', '#aaa');
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('#bcbcbc');
|
||||
testHelpers.assertFieldValue(this.field, '#bcbcbc', '#bcbcbc');
|
||||
assertFieldValue(this.field, '#bcbcbc', '#bcbcbc');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -161,7 +162,7 @@ suite('Colour Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.field.setValue(suiteInfo.value);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
this.field, suiteInfo.expectedValue, suiteInfo.expectedText);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldDropdown');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -74,14 +75,14 @@ suite('Dropdown Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue, testCase.expectedText);
|
||||
assertFieldValue(field, testCase.expectedValue, testCase.expectedText);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldDropdown, validValueCreationTestCases,
|
||||
invalidValueCreationTestCases, validTestCaseAssertField);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldDropdown, validValueCreationTestCases,
|
||||
invalidValueCreationTestCases, validTestCaseAssertField);
|
||||
|
||||
@@ -107,12 +108,12 @@ suite('Dropdown Fields', function() {
|
||||
this.field = new Blockly.FieldDropdown(
|
||||
[['a', 'A'], ['b', 'B'], ['c', 'C']]);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueSetValueTestCases, invalidValueSetValueTestCases, 'A', 'a');
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('B');
|
||||
testHelpers.assertFieldValue(this.field, 'B', 'b');
|
||||
assertFieldValue(this.field, 'B', 'b');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,7 +134,7 @@ suite('Dropdown Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.dropdownField.setValue('1B');
|
||||
testHelpers.assertFieldValue(this.dropdownField, '1A', '1a');
|
||||
assertFieldValue(this.dropdownField, '1A', '1a');
|
||||
});
|
||||
});
|
||||
suite('Force 1s Validator', function() {
|
||||
@@ -144,7 +145,7 @@ suite('Dropdown Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.dropdownField.setValue('2B');
|
||||
testHelpers.assertFieldValue(this.dropdownField, '1B', '1b');
|
||||
assertFieldValue(this.dropdownField, '1B', '1b');
|
||||
});
|
||||
});
|
||||
suite('Returns Undefined Validator', function() {
|
||||
@@ -153,7 +154,7 @@ suite('Dropdown Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.dropdownField.setValue('1B');
|
||||
testHelpers.assertFieldValue(this.dropdownField, '1B', '1b');
|
||||
assertFieldValue(this.dropdownField, '1B', '1b');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldImage');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -56,14 +57,14 @@ suite('Image Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue, testCase.expectedText);
|
||||
assertFieldValue(field, testCase.expectedValue, testCase.expectedText);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldImage, validValueCreationTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldImage, validValueCreationTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField);
|
||||
|
||||
@@ -80,7 +81,7 @@ suite('Image Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldImage('src', 1, 1, 'alt');
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueSetValueTestCases, invalidValueTestCases, 'src', 'alt');
|
||||
});
|
||||
|
||||
@@ -126,15 +127,15 @@ suite('Image Fields', function() {
|
||||
});
|
||||
test('Null', function() {
|
||||
this.imageField.setAlt(null);
|
||||
testHelpers.assertFieldValue(this.imageField, 'src', '');
|
||||
assertFieldValue(this.imageField, 'src', '');
|
||||
});
|
||||
test('Empty String', function() {
|
||||
this.imageField.setAlt('');
|
||||
testHelpers.assertFieldValue(this.imageField, 'src', '');
|
||||
assertFieldValue(this.imageField, 'src', '');
|
||||
});
|
||||
test('Good Alt', function() {
|
||||
this.imageField.setAlt('newAlt');
|
||||
testHelpers.assertFieldValue(this.imageField, 'src', 'newAlt');
|
||||
assertFieldValue(this.imageField, 'src', 'newAlt');
|
||||
});
|
||||
});
|
||||
test('JS Configuration - Simple', function() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldLabelSerialization');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -53,7 +54,7 @@ suite('Label Serializable Fields', function() {
|
||||
* @param {!Blockly.FieldLabelSerializable} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue);
|
||||
assertFieldValue(field, defaultFieldValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -61,14 +62,14 @@ suite('Label Serializable Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldLabelSerializable, validValueTestCases,
|
||||
invalidValueTestCases, validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldLabelSerializable, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -77,12 +78,12 @@ suite('Label Serializable Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldLabelSerializable();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -90,12 +91,12 @@ suite('Label Serializable Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldLabelSerializable(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldLabel');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -53,7 +54,7 @@ suite('Label Fields', function() {
|
||||
* @param {!Blockly.FieldLabel} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue);
|
||||
assertFieldValue(field, defaultFieldValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -61,14 +62,14 @@ suite('Label Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldLabel, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldLabel, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -77,12 +78,12 @@ suite('Label Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldLabel();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -90,12 +91,12 @@ suite('Label Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldLabel(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
goog.module('Blockly.test.fieldMultiline');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
const {runCodeGenerationTestSuites} = goog.require('Blockly.test.blockHelpers');
|
||||
|
||||
|
||||
suite('Multiline Input Fields', function() {
|
||||
@@ -55,7 +57,7 @@ suite('Multiline Input Fields', function() {
|
||||
* @param {!Blockly.FieldMultilineInput} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue);
|
||||
assertFieldValue(field, defaultFieldValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -63,14 +65,14 @@ suite('Multiline Input Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldMultilineInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldMultilineInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -79,12 +81,12 @@ suite('Multiline Input Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldMultilineInput();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -92,12 +94,12 @@ suite('Multiline Input Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldMultilineInput(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -156,7 +158,7 @@ suite('Multiline Input Fields', function() {
|
||||
createBlock: createBlockFn('bark bark\n bark bark bark\n bark bar bark bark\n')},
|
||||
]},
|
||||
];
|
||||
testHelpers.runCodeGenerationTestSuites(testSuites);
|
||||
runCodeGenerationTestSuites(testSuites);
|
||||
});
|
||||
|
||||
suite('Serialization', function() {
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
goog.module('Blockly.test.fieldNumber');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
const {runTestCases} = goog.require('Blockly.test.commonHelpers');
|
||||
|
||||
|
||||
suite('Number Fields', function() {
|
||||
@@ -64,7 +66,7 @@ suite('Number Fields', function() {
|
||||
*/
|
||||
function assertNumberField(field, expectedMin, expectedMax,
|
||||
expectedPrecision, expectedValue) {
|
||||
testHelpers.assertFieldValue(field, expectedValue);
|
||||
assertFieldValue(field, expectedValue);
|
||||
chai.assert.equal(field.getMin(), expectedMin, 'Min');
|
||||
chai.assert.equal(field.getMax(), expectedMax, 'Max');
|
||||
chai.assert.equal(
|
||||
@@ -88,11 +90,11 @@ suite('Number Fields', function() {
|
||||
testCase.expectedValue, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldNumber, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldNumber, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -101,7 +103,7 @@ suite('Number Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldNumber();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -109,7 +111,7 @@ suite('Number Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldNumber(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
});
|
||||
suite('Constraints', function() {
|
||||
@@ -127,11 +129,11 @@ suite('Number Fields', function() {
|
||||
expectedValue: 123},
|
||||
];
|
||||
suite('Precision', function() {
|
||||
testHelpers.runTestCases(testCases, function(testCase) {
|
||||
runTestCases(testCases, function(testCase) {
|
||||
return function() {
|
||||
const field = Blockly.FieldNumber.fromJson(testCase.json);
|
||||
field.setValue(testCase.value);
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
});
|
||||
test('Null', function() {
|
||||
@@ -144,7 +146,7 @@ suite('Number Fields', function() {
|
||||
const field = Blockly.FieldNumber.fromJson(testCase.json);
|
||||
testCase.values.forEach(function(value, i) {
|
||||
field.setValue(value);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
field, testCase.expectedValues[i]);
|
||||
});
|
||||
};
|
||||
@@ -158,7 +160,7 @@ suite('Number Fields', function() {
|
||||
{title: '+10', json: {min: 10}, values: [-20, 0, 20],
|
||||
expectedValues: [10, 10, 20]},
|
||||
];
|
||||
testHelpers.runTestCases(testCases, setValueBoundsTestFn);
|
||||
runTestCases(testCases, setValueBoundsTestFn);
|
||||
test('Null', function() {
|
||||
const field = Blockly.FieldNumber.fromJson({min: null});
|
||||
chai.assert.equal(field.getMin(), -Infinity);
|
||||
@@ -173,7 +175,7 @@ suite('Number Fields', function() {
|
||||
{title: '+10', json: {max: 10}, values: [-20, 0, 20],
|
||||
expectedValues: [-20, 0, 10]},
|
||||
];
|
||||
testHelpers.runTestCases(testCases, setValueBoundsTestFn);
|
||||
runTestCases(testCases, setValueBoundsTestFn);
|
||||
test('Null', function() {
|
||||
const field = Blockly.FieldNumber.fromJson({max: null});
|
||||
chai.assert.equal(field.getMax(), Infinity);
|
||||
@@ -217,12 +219,12 @@ suite('Number Fields', function() {
|
||||
this.field.isBeingEdited_ = true;
|
||||
this.field.htmlInput_.value = String(suiteInfo.value);
|
||||
this.field.onHtmlInputChange_(null);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
this.field, suiteInfo.expectedValue, String(suiteInfo.value));
|
||||
});
|
||||
test('When Not Editing', function() {
|
||||
this.field.setValue(suiteInfo.value);
|
||||
testHelpers.assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldTextInput');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -53,7 +54,7 @@ suite('Text Input Fields', function() {
|
||||
* @param {!Blockly.FieldTextInput} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, defaultFieldValue);
|
||||
assertFieldValue(field, defaultFieldValue);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -61,14 +62,14 @@ suite('Text Input Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, testCase.expectedValue);
|
||||
assertFieldValue(field, testCase.expectedValue);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldTextInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldTextInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
@@ -77,12 +78,12 @@ suite('Text Input Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldTextInput();
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, defaultFieldValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
@@ -90,12 +91,12 @@ suite('Text Input Fields', function() {
|
||||
setup(function() {
|
||||
this.field = new Blockly.FieldTextInput(initialValue);
|
||||
});
|
||||
testHelpers.runSetValueTests(
|
||||
runSetValueTests(
|
||||
validValueTestCases, invalidValueTestCases, initialValue);
|
||||
test('With source block', function() {
|
||||
this.field.setSourceBlock(createTestBlock());
|
||||
this.field.setValue('value');
|
||||
testHelpers.assertFieldValue(this.field, 'value');
|
||||
assertFieldValue(this.field, 'value');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -136,12 +137,12 @@ suite('Text Input Fields', function() {
|
||||
this.field.isBeingEdited_ = true;
|
||||
this.field.htmlInput_.value = suiteInfo.value;
|
||||
this.field.onHtmlInputChange_(null);
|
||||
testHelpers.assertFieldValue(
|
||||
assertFieldValue(
|
||||
this.field, suiteInfo.expectedValue, suiteInfo.value);
|
||||
});
|
||||
test('When Not Editing', function() {
|
||||
this.field.setValue(suiteInfo.value);
|
||||
testHelpers.assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
assertFieldValue(this.field, suiteInfo.expectedValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.fieldVariable');
|
||||
|
||||
const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.fieldHelpers');
|
||||
const {createGenUidStubWithReturns, createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ suite('Variable Fields', function() {
|
||||
* @param {!Blockly.FieldVariable} field The field to check.
|
||||
*/
|
||||
const assertFieldDefault = function(field) {
|
||||
testHelpers.assertFieldValue(field, FAKE_ID, defaultFieldName);
|
||||
assertFieldValue(field, FAKE_ID, defaultFieldName);
|
||||
};
|
||||
/**
|
||||
* Asserts that the field properties are correct based on the test case.
|
||||
@@ -91,15 +92,15 @@ suite('Variable Fields', function() {
|
||||
* @param {!FieldValueTestCase} testCase The test case.
|
||||
*/
|
||||
const validTestCaseAssertField = function(field, testCase) {
|
||||
testHelpers.assertFieldValue(field, FAKE_ID, testCase.expectedText);
|
||||
assertFieldValue(field, FAKE_ID, testCase.expectedText);
|
||||
};
|
||||
|
||||
testHelpers.runConstructorSuiteTests(
|
||||
runConstructorSuiteTests(
|
||||
Blockly.FieldVariable, validValueCreationTestCases,
|
||||
invalidValueCreationTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault, customCreateWithJs);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
runFromJsonSuiteTests(
|
||||
Blockly.FieldVariable, validValueCreationTestCases,
|
||||
invalidValueCreationTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault, customCreateWithJson);
|
||||
@@ -149,7 +150,7 @@ suite('Variable Fields', function() {
|
||||
teardown(function() {
|
||||
console.warn = this.nativeConsoleWarn;
|
||||
});
|
||||
testHelpers.runSetValueTests(validValueTestCases, invalidValueTestCases,
|
||||
runSetValueTests(validValueTestCases, invalidValueTestCases,
|
||||
FAKE_ID, defaultFieldName);
|
||||
});
|
||||
|
||||
@@ -215,7 +216,7 @@ suite('Variable Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.variableField.setValue('id2');
|
||||
testHelpers.assertFieldValue(this.variableField, 'id1', 'name1');
|
||||
assertFieldValue(this.variableField, 'id1', 'name1');
|
||||
});
|
||||
});
|
||||
suite('Force \'id\' ID Validator', function() {
|
||||
@@ -228,7 +229,7 @@ suite('Variable Fields', function() {
|
||||
// Must create the var so that the field doesn't throw an error.
|
||||
this.workspace.createVariable('thing2', null, 'other2');
|
||||
this.variableField.setValue('other2');
|
||||
testHelpers.assertFieldValue(this.variableField, 'id2', 'name2');
|
||||
assertFieldValue(this.variableField, 'id2', 'name2');
|
||||
});
|
||||
});
|
||||
suite('Returns Undefined Validator', function() {
|
||||
@@ -237,7 +238,7 @@ suite('Variable Fields', function() {
|
||||
});
|
||||
test('New Value', function() {
|
||||
this.variableField.setValue('id2');
|
||||
testHelpers.assertFieldValue(this.variableField, 'id2', 'name2');
|
||||
assertFieldValue(this.variableField, 'id2', 'name2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<script src="../../node_modules/chai/chai.js"></script>
|
||||
<script src="../../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../../node_modules/sinon/pkg/sinon.js"></script>
|
||||
<script src="../../node_modules/@blockly/dev-tools/dist/index.js"></script>
|
||||
<!-- <script src="../../node_modules/@blockly/dev-tools/dist/index.js"></script> -->
|
||||
<script>
|
||||
mocha.setup({
|
||||
ui: 'tdd'
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
goog.module('Blockly.test.logicTernary');
|
||||
|
||||
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
|
||||
const eventUtils = goog.require('Blockly.Events.utils');
|
||||
const {runSerializationTestSuite} = goog.require('Blockly.test.blockHelpers');
|
||||
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
suite('Logic ternary', function() {
|
||||
@@ -73,7 +74,7 @@ suite('Logic ternary', function() {
|
||||
},
|
||||
},
|
||||
];
|
||||
testHelpers.runSerializationTestSuite(testCases);
|
||||
runSerializationTestSuite(testCases);
|
||||
|
||||
suite('Connections', function() {
|
||||
function connectParentAndCheckConnections(
|
||||
|
||||
@@ -8,8 +8,9 @@ goog.module('Blockly.test.procedures');
|
||||
|
||||
goog.require('Blockly');
|
||||
goog.require('Blockly.Msg');
|
||||
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
const {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, createProcCallBlock} = goog.require('Blockly.test.procedureHelpers');
|
||||
const {runSerializationTestSuite} = goog.require('Blockly.test.blockHelpers');
|
||||
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
suite('Procedures', function() {
|
||||
@@ -1203,7 +1204,7 @@ suite('Procedures', function() {
|
||||
},
|
||||
},
|
||||
];
|
||||
testHelpers.runSerializationTestSuite(testCases);
|
||||
runSerializationTestSuite(testCases);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.serialization');
|
||||
|
||||
const {TestCase, TestSuite, runTestCases, runTestSuites} = goog.require('Blockly.test.commonHelpers');
|
||||
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
|
||||
|
||||
|
||||
@@ -23,7 +24,7 @@ function SerializerTestCase(title, xml) {
|
||||
this.title = title;
|
||||
this.xml = xml;
|
||||
}
|
||||
SerializerTestCase.prototype = new testHelpers.TestCase();
|
||||
SerializerTestCase.prototype = new TestCase();
|
||||
|
||||
/**
|
||||
* The XML we want to ensure round-trips through the serializer.
|
||||
@@ -39,7 +40,7 @@ SerializerTestCase.prototype.xml = '';
|
||||
function SerializerTestSuite(title) {
|
||||
this.title = title;
|
||||
}
|
||||
SerializerTestSuite.prototype = new testHelpers.TestSuite();
|
||||
SerializerTestSuite.prototype = new TestSuite();
|
||||
|
||||
const Serializer = new SerializerTestSuite('Serializer');
|
||||
|
||||
@@ -1818,9 +1819,9 @@ const runSerializerTestSuite = (serializer, deserializer, testSuite) => {
|
||||
sharedTestTeardown.call(this);
|
||||
});
|
||||
|
||||
testHelpers.runTestSuites(
|
||||
runTestSuites(
|
||||
testSuite.testSuites, createTestCaseFunction);
|
||||
testHelpers.runTestCases(testSuite.testCases, createTestFunction);
|
||||
runTestCases(testSuite.testCases, createTestFunction);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
goog.module('Blockly.test.helpers');
|
||||
|
||||
const {captureWarnings} = goog.require('Blockly.test.commonHelpers');
|
||||
const {KeyCodes} = goog.require('Blockly.utils.KeyCodes');
|
||||
const eventUtils = goog.require('Blockly.Events.utils');
|
||||
const {Blocks} = goog.require('Blockly.blocks');
|
||||
@@ -38,7 +39,7 @@ function assertWarnings(innerFunc, messages) {
|
||||
if (!Array.isArray(messages)) {
|
||||
messages = [messages];
|
||||
}
|
||||
const warnings = testHelpers.captureWarnings(innerFunc);
|
||||
const warnings = captureWarnings(innerFunc);
|
||||
chai.assert.lengthOf(warnings, messages.length);
|
||||
messages.forEach((message, i) => {
|
||||
chai.assert.match(warnings[i], message);
|
||||
|
||||
Reference in New Issue
Block a user