Fixed unit tests.

This commit is contained in:
Beka Westberg
2019-06-07 07:22:08 -07:00
parent 303115953e
commit 81035c3bcb
4 changed files with 20 additions and 28 deletions

View File

@@ -88,14 +88,6 @@ Blockly.FieldTextInput.prototype.SERIALIZABLE = true;
*/
Blockly.FieldTextInput.FONTSIZE = 11;
/**
* The HTML input element for the user to type, or null if no FieldTextInput
* editor is currently open.
* @type {HTMLInputElement}
* @protected
*/
Blockly.FieldTextInput.htmlInput_ = null;
/**
* Mouse cursor style when over the hotspot that initiates the editor.
*/

View File

@@ -201,13 +201,13 @@ suite ('Angle Fields', function() {
suite('Validators', function() {
setup(function() {
this.angleField = new Blockly.FieldAngle(1);
Blockly.FieldTextInput.htmlInput_ = Object.create(null);
Blockly.FieldTextInput.htmlInput_.oldValue_ = '1';
Blockly.FieldTextInput.htmlInput_.untypedDefaultValue_ = 1;
this.angleField.htmlInput_ = Object.create(null);
this.angleField.htmlInput_.oldValue_ = '1';
this.angleField.htmlInput_.untypedDefaultValue_ = 1;
});
teardown(function() {
this.angleField.setValidator(null);
Blockly.FieldTextInput.htmlInput_ = null;
this.angleField.htmlInput_ = null;
});
suite('Null Validator', function() {
setup(function() {
@@ -217,7 +217,7 @@ suite ('Angle Fields', function() {
});
test('When Editing', function() {
this.angleField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '2';
this.angleField.htmlInput_.value = '2';
this.angleField.onHtmlInputChange_(null);
assertValue(this.angleField, 1, '2');
this.angleField.isBeingEdited_ = false;
@@ -235,7 +235,7 @@ suite ('Angle Fields', function() {
});
test('When Editing', function() {
this.angleField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '25';
this.angleField.htmlInput_.value = '25';
this.angleField.onHtmlInputChange_(null);
assertValue(this.angleField, 30, '25');
this.angleField.isBeingEdited_ = false;
@@ -251,7 +251,7 @@ suite ('Angle Fields', function() {
});
test('When Editing', function() {
this.angleField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '2';
this.angleField.htmlInput_.value = '2';
this.angleField.onHtmlInputChange_(null);
assertValue(this.angleField, 2);
this.angleField.isBeingEdited_ = false;

View File

@@ -298,13 +298,13 @@ suite ('Number Fields', function() {
suite('Validators', function() {
setup(function() {
this.numberField = new Blockly.FieldNumber(1);
Blockly.FieldTextInput.htmlInput_ = Object.create(null);
Blockly.FieldTextInput.htmlInput_.oldValue_ = '1';
Blockly.FieldTextInput.htmlInput_.untypedDefaultValue_ = 1;
this.numberField.htmlInput_ = Object.create(null);
this.numberField.htmlInput_.oldValue_ = '1';
this.numberField.htmlInput_.untypedDefaultValue_ = 1;
});
teardown(function() {
this.numberField.setValidator(null);
Blockly.FieldTextInput.htmlInput_ = null;
this.numberField.htmlInput_ = null;
});
suite('Null Validator', function() {
setup(function() {
@@ -314,7 +314,7 @@ suite ('Number Fields', function() {
});
test('When Editing', function() {
this.numberField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '2';
this.numberField.htmlInput_.value = '2';
this.numberField.onHtmlInputChange_(null);
assertValue(this.numberField, 1, '2');
this.numberField.isBeingEdited_ = false;
@@ -332,7 +332,7 @@ suite ('Number Fields', function() {
});
test('When Editing', function() {
this.numberField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '25';
this.numberField.htmlInput_.value = '25';
this.numberField.onHtmlInputChange_(null);
assertValue(this.numberField, 26, '25');
this.numberField.isBeingEdited_ = false;
@@ -348,7 +348,7 @@ suite ('Number Fields', function() {
});
test('When Editing', function() {
this.numberField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = '2';
this.numberField.htmlInput_.value = '2';
this.numberField.onHtmlInputChange_(null);
assertValue(this.numberField, 2);
this.numberField.isBeingEdited_ = false;

View File

@@ -169,9 +169,9 @@ suite ('Text Input Fields', function() {
suite('Validators', function() {
setup(function() {
this.textInputField = new Blockly.FieldTextInput('value');
Blockly.FieldTextInput.htmlInput_ = Object.create(null);
Blockly.FieldTextInput.htmlInput_.oldValue_ = 'value';
Blockly.FieldTextInput.htmlInput_.untypedDefaultValue_ = 'value';
this.textInputField.htmlInput_ = Object.create(null);
this.textInputField.htmlInput_.oldValue_ = 'value';
this.textInputField.htmlInput_.untypedDefaultValue_ = 'value';
});
teardown(function() {
this.textInputField.setValidator(null);
@@ -185,7 +185,7 @@ suite ('Text Input Fields', function() {
});
test('When Editing', function() {
this.textInputField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = 'newValue';
this.textInputField.htmlInput_.value = 'newValue';
this.textInputField.onHtmlInputChange_(null);
assertValue(this.textInputField, 'value', 'newValue');
this.textInputField.isBeingEdited_ = false;
@@ -203,7 +203,7 @@ suite ('Text Input Fields', function() {
});
test('When Editing', function() {
this.textInputField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = 'bbbaaa';
this.textInputField.htmlInput_.value = 'bbbaaa';
this.textInputField.onHtmlInputChange_(null);
assertValue(this.textInputField, 'bbb', 'bbbaaa');
this.textInputField.isBeingEdited_ = false;
@@ -219,7 +219,7 @@ suite ('Text Input Fields', function() {
});
test('When Editing', function() {
this.textInputField.isBeingEdited_ = true;
Blockly.FieldTextInput.htmlInput_.value = 'newValue';
this.textInputField.htmlInput_.value = 'newValue';
this.textInputField.onHtmlInputChange_(null);
assertValue(this.textInputField, 'newValue');
this.textInputField.isBeingEdited_ = false;