1
0
mirror of synced 2024-11-22 21:16:10 +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);
data.current(function (val) {
assert.deepEqual(
val,
[],
assert.equal(
val.length,
0,
'There should be no default selection.'
);
});
@ -41,9 +41,9 @@ test('current gets default for multiple', function (assert) {
var data = new ArrayData($select, options);
data.current(function (val) {
assert.deepEqual(
val,
[],
assert.equal(
val.length,
0,
'There should be no default selection.'
);
});
@ -57,14 +57,24 @@ test('current works with existing selections', function (assert) {
$select.val(['3']);
data.current(function (val) {
assert.deepEqual(
val,
[{
id: '3',
text: 'Three',
disabled: false
}],
'The text and id should match the value and text for the option tag.'
assert.equal(
val.length,
1,
'There should only be one existing selection'
);
var option = val[0];
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);
data.current(function (val) {
assert.deepEqual(
val,
[{
id: 'default',
text: 'Default',
disabled: false
}],
'The first option should be selected by default (by the browser).'
assert.equal(
val.length,
1,
'There should only be one selected option'
);
var option = val[0];
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);
data.current(function (val) {
assert.deepEqual(
val,
[],
assert.equal(
val.length,
0,
'Multiple selects have no default selection.'
);
});
@ -46,14 +56,24 @@ test('current gets options with explicit value', function (assert) {
$select.val('1');
data.current(function (val) {
assert.deepEqual(
val,
[{
id: '1',
text: 'One',
disabled: false
}],
'The text and id should match the value and text for the option tag.'
assert.equal(
val.length,
1,
'There should be one selected option'
);
var option = val[0];
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');
data.current(function (val) {
assert.deepEqual(
val,
[{
id: '2',
text: '2',
disabled: false
}],
'The text and id should match the text within the option tag.'
assert.equal(
val.length,
1,
'There should only be one selected value'
);
var option = val[0];
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'
);
});
});