1
0
mirror of synced 2024-11-26 14:56:07 +03:00

Changed tests to not use deepEqual

We should only be checking the option values that matter, such as
`id` and `text`, instead of checking all of the option values. This
will prevent unexpected breaking when new properties are added to
the options.

Existing properties should be covered by tests to avoid regressions.
This commit is contained in:
Kevin Brown 2014-10-19 17:15:32 -04:00
parent 9102cf9473
commit e018a6f69e
4 changed files with 84 additions and 44 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,9 +27,9 @@ test('current gets default for single', function (assert) {
var data = new ArrayData($select, options); var data = new ArrayData($select, options);
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[], 0,
'There should be no default selection.' 'There should be no default selection.'
); );
}); });
@ -41,9 +41,9 @@ test('current gets default for multiple', function (assert) {
var data = new ArrayData($select, options); var data = new ArrayData($select, options);
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[], 0,
'There should be no default selection.' 'There should be no default selection.'
); );
}); });
@ -57,14 +57,24 @@ test('current works with existing selections', function (assert) {
$select.val(['3']); $select.val(['3']);
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[{ 1,
id: '3', 'There should only be one existing selection'
text: 'Three', );
disabled: false
}], var option = val[0];
'The text and id should match the value and text for the option tag.'
assert.equal(
option.id,
'3',
'The id should be equal to the value of the option tag'
);
assert.equal(
option.text,
'Three',
'The text should be equal to the text of the option tag'
); );
}); });
}); });

View File

@ -12,14 +12,24 @@ test('current gets default for single', function (assert) {
var data = new SelectData($select, options); var data = new SelectData($select, options);
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[{ 1,
id: 'default', 'There should only be one selected option'
text: 'Default', );
disabled: false
}], var option = val[0];
'The first option should be selected by default (by the browser).'
assert.equal(
option.id,
'default',
'The value of the option tag should be the id'
);
assert.equal(
option.text,
'Default',
'The text within the option tag should be the text'
); );
}); });
}); });
@ -30,9 +40,9 @@ test('current gets default for multiple', function (assert) {
var data = new SelectData($select, options); var data = new SelectData($select, options);
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[], 0,
'Multiple selects have no default selection.' 'Multiple selects have no default selection.'
); );
}); });
@ -46,14 +56,24 @@ test('current gets options with explicit value', function (assert) {
$select.val('1'); $select.val('1');
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[{ 1,
id: '1', 'There should be one selected option'
text: 'One', );
disabled: false
}], var option = val[0];
'The text and id should match the value and text for the option tag.'
assert.equal(
option.id,
'1',
'The option value should be the selected id'
);
assert.equal(
option.text,
'One',
'The text should match the text for the option tag'
); );
}); });
}); });
@ -66,14 +86,24 @@ test('current gets options with implicit value', function (assert) {
$select.val('2'); $select.val('2');
data.current(function (val) { data.current(function (val) {
assert.deepEqual( assert.equal(
val, val.length,
[{ 1,
id: '2', 'There should only be one selected value'
text: '2', );
disabled: false
}], var option = val[0];
'The text and id should match the text within the option tag.'
assert.equal(
option.id,
'2',
'The id should be the same as the option text'
);
assert.equal(
option.text,
'2',
'The text should be the same as the option text'
); );
}); });
}); });