From c8e3938ebab7b0e8f907eb9c07d430b1cea6379b Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 31 Jul 2019 18:14:46 -0700 Subject: [PATCH] Remove field tests with null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Null is explicitly disallowed in most field constructors. Thus the random results of passing null are undefined and may change. These changes should not be tested against. Exceptions: Variable and serializable lable fields acually do take null. This commit is due to the upcoming parseInt->Number commit which happens to change how null behaves. Also added missing ‘empty’ test for checkboxes. --- tests/mocha/field_angle_test.js | 8 -------- tests/mocha/field_checkbox_test.js | 8 ++++---- tests/mocha/field_colour_test.js | 8 -------- tests/mocha/field_date_test.js | 8 -------- tests/mocha/field_dropdown_test.js | 10 ---------- tests/mocha/field_image_test.js | 28 ---------------------------- tests/mocha/field_label_test.js | 8 -------- tests/mocha/field_number_test.js | 8 -------- tests/mocha/field_textinput_test.js | 8 -------- 9 files changed, 4 insertions(+), 90 deletions(-) diff --git a/tests/mocha/field_angle_test.js b/tests/mocha/field_angle_test.js index fee8f813e..75a34d2b0 100644 --- a/tests/mocha/field_angle_test.js +++ b/tests/mocha/field_angle_test.js @@ -35,10 +35,6 @@ suite('Angle Fields', function() { var angleField = new Blockly.FieldAngle(); assertValueDefault(angleField); }); - test('Null', function() { - var angleField = new Blockly.FieldAngle(null); - assertValueDefault(angleField); - }); test('Undefined', function() { var angleField = new Blockly.FieldAngle(undefined); assertValueDefault(angleField); @@ -77,10 +73,6 @@ suite('Angle Fields', function() { var angleField = Blockly.FieldAngle.fromJson({}); assertValueDefault(angleField); }); - test('Null', function() { - var angleField = Blockly.FieldAngle.fromJson({ angle:null }); - assertValueDefault(angleField); - }); test('Undefined', function() { var angleField = Blockly.FieldAngle.fromJson({ angle:undefined }); assertValueDefault(angleField); diff --git a/tests/mocha/field_checkbox_test.js b/tests/mocha/field_checkbox_test.js index dc55e2b3b..8ef2f322d 100644 --- a/tests/mocha/field_checkbox_test.js +++ b/tests/mocha/field_checkbox_test.js @@ -29,8 +29,8 @@ suite('Checkbox Fields', function() { assertValue(checkboxField, 'FALSE', 'false'); } suite('Constructor', function() { - test('Null', function() { - var checkboxField = new Blockly.FieldCheckbox(null); + test('Empty', function() { + var checkboxField = new Blockly.FieldCheckbox(); assertValueDefault(checkboxField); }); test('Undefined', function() { @@ -59,8 +59,8 @@ suite('Checkbox Fields', function() { }); }); suite('fromJson', function() { - test('Null', function() { - var checkboxField = Blockly.FieldCheckbox.fromJson({ checked: null}); + test('Empty', function() { + var checkboxField = Blockly.FieldCheckbox.fromJson({}); assertValueDefault(checkboxField); }); test('Undefined', function() { diff --git a/tests/mocha/field_colour_test.js b/tests/mocha/field_colour_test.js index 39ef4c631..28d5cc43f 100644 --- a/tests/mocha/field_colour_test.js +++ b/tests/mocha/field_colour_test.js @@ -49,10 +49,6 @@ suite('Colour Fields', function() { var colourField = new Blockly.FieldColour(); assertValueDefault(colourField); }); - test('Null', function() { - var colourField = new Blockly.FieldColour(null); - assertValueDefault(colourField); - }); test('Undefined', function() { var colourField = new Blockly.FieldColour(undefined); assertValueDefault(colourField); @@ -107,10 +103,6 @@ suite('Colour Fields', function() { var colourField = new Blockly.FieldColour.fromJson({}); assertValueDefault(colourField); }); - test('Null', function() { - var colourField = new Blockly.FieldColour.fromJson({ colour:null }); - assertValueDefault(colourField); - }); test('Undefined', function() { var colourField = new Blockly.FieldColour.fromJson({ colour:undefined }); assertValueDefault(colourField); diff --git a/tests/mocha/field_date_test.js b/tests/mocha/field_date_test.js index 05620e95b..6945882c8 100644 --- a/tests/mocha/field_date_test.js +++ b/tests/mocha/field_date_test.js @@ -34,10 +34,6 @@ suite('Date Fields', function() { var dateField = new Blockly.FieldDate(); assertValueDefault(dateField); }); - test('Null', function() { - var dateField = new Blockly.FieldDate(null); - assertValueDefault(dateField); - }); test('Undefined', function() { var dateField = new Blockly.FieldDate(undefined); assertValueDefault(dateField); @@ -64,10 +60,6 @@ suite('Date Fields', function() { var dateField = Blockly.FieldDate.fromJson({}); assertValueDefault(dateField); }); - test('Null', function() { - var dateField = Blockly.FieldDate.fromJson({ date: null }); - assertValueDefault(dateField); - }); test('Undefined', function() { var dateField = Blockly.FieldDate.fromJson({ date: undefined }); assertValueDefault(dateField); diff --git a/tests/mocha/field_dropdown_test.js b/tests/mocha/field_dropdown_test.js index c7499fd26..307e52edf 100644 --- a/tests/mocha/field_dropdown_test.js +++ b/tests/mocha/field_dropdown_test.js @@ -31,11 +31,6 @@ suite('Dropdown Fields', function() { new Blockly.FieldDropdown(); }); }); - test('Null', function() { - chai.assert.throws(function() { - new Blockly.FieldDropdown(null); - }); - }); test('Undefined', function() { chai.assert.throws(function() { new Blockly.FieldDropdown(undefined); @@ -102,11 +97,6 @@ suite('Dropdown Fields', function() { Blockly.FieldDropdown.fromJson({}); }); }); - test('Null', function() { - chai.assert.throws(function() { - Blockly.FieldDropdown.fromJson({ options: null }); - }); - }); test('Undefined', function() { chai.assert.throws(function() { Blockly.FieldDropdown.fromJson({ options: undefined }); diff --git a/tests/mocha/field_image_test.js b/tests/mocha/field_image_test.js index e7a317cbe..fda439641 100644 --- a/tests/mocha/field_image_test.js +++ b/tests/mocha/field_image_test.js @@ -31,21 +31,11 @@ suite('Image Fields', function() { new Blockly.FieldImage(); }); }); - test('Null Src', function() { - chai.assert.throws(function() { - new Blockly.FieldImage(null, 1, 1); - }); - }); test('Undefined Src', function() { chai.assert.throws(function() { new Blockly.FieldImage(undefined, 1, 1); }); }); - test('Null Size', function() { - chai.assert.throws(function() { - new Blockly.FieldImage('src', null, null); - }); - }); test('Undefined Size', function() { chai.assert.throws(function() { new Blockly.FieldImage('src', undefined, undefined); @@ -79,15 +69,6 @@ suite('Image Fields', function() { Blockly.FieldImage.fromJson({}); }); }); - test('Null Src', function() { - chai.assert.throws(function() { - Blockly.FieldImage.fromJson({ - src: null, - width: 1, - height: 1 - }); - }); - }); test('Undefined Src', function() { chai.assert.throws(function() { Blockly.FieldImage.fromJson({ @@ -97,15 +78,6 @@ suite('Image Fields', function() { }); }); }); - test('Null Size', function() { - chai.assert.throws(function() { - Blockly.FieldImage.fromJson({ - src: 'src', - width: null, - height: null - }); - }); - }); test('Undefined Size', function() { chai.assert.throws(function() { Blockly.FieldImage.fromJson({ diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js index 8cba0f472..8e6e53358 100644 --- a/tests/mocha/field_label_test.js +++ b/tests/mocha/field_label_test.js @@ -33,10 +33,6 @@ suite('Label Fields', function() { var labelField = new Blockly.FieldLabel(); assertValueDefault(labelField); }); - test('Null', function() { - var labelField = new Blockly.FieldLabel(null); - assertValueDefault(labelField); - }); test('Undefined', function() { var labelField = new Blockly.FieldLabel(undefined); assertValueDefault(labelField); @@ -67,10 +63,6 @@ suite('Label Fields', function() { var labelField = new Blockly.FieldLabel.fromJson({}); assertValueDefault(labelField); }); - test('Null', function() { - var labelField = new Blockly.FieldLabel.fromJson({ text:null }); - assertValueDefault(labelField); - }); test('Undefined', function() { var labelField = new Blockly.FieldLabel.fromJson({ text:undefined }); assertValueDefault(labelField); diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index d78b5e29c..c41fb33a2 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -55,10 +55,6 @@ suite('Number Fields', function() { var numberField = new Blockly.FieldNumber(); assertNumberFieldDefault(numberField); }); - test('Null', function() { - var numberField = createNumberFieldSameValuesConstructor(null); - assertNumberFieldDefault(numberField); - }); test('Undefined', function() { var numberField = createNumberFieldSameValuesConstructor(undefined); assertNumberFieldDefault(numberField); @@ -93,10 +89,6 @@ suite('Number Fields', function() { var numberField = Blockly.FieldNumber.fromJson({}); assertNumberFieldDefault(numberField); }); - test('Null', function() { - var numberField = createNumberFieldSameValuesJson(null); - assertNumberFieldDefault(numberField); - }); test('Undefined', function() { var numberField = createNumberFieldSameValuesJson(undefined); assertNumberFieldDefault(numberField); diff --git a/tests/mocha/field_textinput_test.js b/tests/mocha/field_textinput_test.js index 27855a90e..4177330a5 100644 --- a/tests/mocha/field_textinput_test.js +++ b/tests/mocha/field_textinput_test.js @@ -34,10 +34,6 @@ suite('Text Input Fields', function() { var textInputField = new Blockly.FieldTextInput(); assertValueDefault(textInputField); }); - test('Null', function() { - var textInputField = new Blockly.FieldTextInput(null); - assertValueDefault(textInputField); - }); test('Undefined', function() { var textInputField = new Blockly.FieldTextInput(undefined); assertValueDefault(textInputField); @@ -68,10 +64,6 @@ suite('Text Input Fields', function() { var textInputField = new Blockly.FieldTextInput.fromJson({}); assertValueDefault(textInputField); }); - test('Null', function() { - var textInputField = new Blockly.FieldTextInput.fromJson({ text: null}); - assertValueDefault(textInputField); - }); test('Undefined', function() { var textInputField = new Blockly.FieldTextInput .fromJson({ text: undefined});