mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
Add field set source block tests (#3796)
* Set the source block on fields in mocha tests.
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
"assertNotUndefined": true,
|
||||
"defineStackBlock": true,
|
||||
"defineRowBlock": true,
|
||||
"defineStatementBlock": true
|
||||
|
||||
"defineStatementBlock": true,
|
||||
"createTestBlock": true
|
||||
},
|
||||
"extends": "../../.eslintrc.json"
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ suite('Angle Fields', function() {
|
||||
this.angleField.setValue('-Infinity');
|
||||
assertValueDefault(this.angleField);
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.angleField.setSourceBlock(createTestBlock());
|
||||
this.angleField.setValue(2.5);
|
||||
assertValue(this.angleField, 2.5);
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -87,6 +87,11 @@ suite('Checkbox Fields', function() {
|
||||
this.checkboxField.setValue('FALSE');
|
||||
assertValue(this.checkboxField, 'FALSE', 'false');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.checkboxField.setSourceBlock(createTestBlock());
|
||||
this.checkboxField.setValue('FALSE');
|
||||
assertValue(this.checkboxField, 'FALSE', 'false');
|
||||
});
|
||||
});
|
||||
suite('False -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -168,6 +168,11 @@ suite('Colour Fields', function() {
|
||||
this.colourField.setValue('red');
|
||||
assertValue(this.colourField, '#ff0000', '#f00');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.colourField.setSourceBlock(createTestBlock());
|
||||
this.colourField.setValue('#bcbcbc');
|
||||
assertValue(this.colourField, '#bcbcbc', '#bcbcbc');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -148,6 +148,11 @@ suite('Dropdown Fields', function() {
|
||||
this.dropdownField.setValue('B');
|
||||
assertValue(this.dropdownField, 'B', 'b');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.dropdownField.setSourceBlock(createTestBlock());
|
||||
this.dropdownField.setValue('B');
|
||||
assertValue(this.dropdownField, 'B', 'b');
|
||||
});
|
||||
});
|
||||
suite('Validators', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -136,6 +136,11 @@ suite('Label Serializable Fields', function() {
|
||||
this.labelField.setValue(false);
|
||||
assertValue(this.labelField, 'false');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.labelField.setSourceBlock(createTestBlock());
|
||||
this.labelField.setValue('newValue');
|
||||
assertValue(this.labelField, 'newValue');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -125,6 +125,11 @@ suite('Label Fields', function() {
|
||||
this.labelField.setValue(false);
|
||||
assertValue(this.labelField, 'false');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.labelField.setSourceBlock(createTestBlock());
|
||||
this.labelField.setValue('newValue');
|
||||
assertValue(this.labelField, 'newValue');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -158,6 +158,11 @@ suite('Number Fields', function() {
|
||||
this.numberField.setValue('-Infinity');
|
||||
assertValue(this.numberField, -Infinity);
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.numberField.setSourceBlock(createTestBlock());
|
||||
this.numberField.setValue(2.5);
|
||||
assertValue(this.numberField, 2.5);
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -109,6 +109,11 @@ suite('Text Input Fields', function() {
|
||||
this.textInputField.setValue(false);
|
||||
assertValue(this.textInputField, 'false');
|
||||
});
|
||||
test('With source block', function() {
|
||||
this.textInputField.setSourceBlock(createTestBlock());
|
||||
this.textInputField.setValue('newValue');
|
||||
assertValue(this.textInputField, 'newValue');
|
||||
});
|
||||
});
|
||||
suite('Value -> New Value', function() {
|
||||
setup(function() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/* exported assertEquals, assertNotEquals, assertArrayEquals, assertTrue, assertFalse,
|
||||
assertNull, assertNotNull, assertNotNullNorUndefined, assert,
|
||||
isEqualArrays, assertUndefined, assertNotUndefined,
|
||||
defineRowBlock, defineStackBlock, defineStatementBlock */
|
||||
defineRowBlock, defineStackBlock, defineStatementBlock, createTestBlock */
|
||||
function _argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
|
||||
return args.length == expectedNumberOfNonCommentArgs + 1;
|
||||
}
|
||||
@@ -181,3 +181,13 @@ function defineStatementBlock() {
|
||||
"helpUrl": ""
|
||||
}]);
|
||||
}
|
||||
|
||||
function createTestBlock() {
|
||||
return {
|
||||
id: 'test',
|
||||
rendered: false,
|
||||
workspace: {
|
||||
rendered: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user