Add field set source block tests (#3796)

* Set the source block on fields in mocha tests.
This commit is contained in:
Sam El-Husseini
2020-04-03 14:50:33 -07:00
committed by GitHub
parent 06f6c22a27
commit 4f9b4a707a
10 changed files with 53 additions and 3 deletions

View File

@@ -16,8 +16,8 @@
"assertNotUndefined": true,
"defineStackBlock": true,
"defineRowBlock": true,
"defineStatementBlock": true
"defineStatementBlock": true,
"createTestBlock": true
},
"extends": "../../.eslintrc.json"
}

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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
}
};
}