-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Add automatic labels in test.each() for primitive values in arrays
Fixes #1733.
- Loading branch information
Showing
6 changed files
with
145 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Automatic labels for test.each() array data where possible | ||
// https://github.com/qunitjs/qunit/issues/1733 | ||
|
||
QUnit.test.each('array of arrays', [[1, 2, 3], [1, 1, 2]], function (assert, _data) { | ||
assert.true(true); | ||
}); | ||
|
||
QUnit.test.each('array of strings', [ | ||
'foo', | ||
'', | ||
' ', | ||
'x'.repeat(40), | ||
'$', | ||
'http://example.org', | ||
'999: example', | ||
'\b', | ||
'\n', | ||
'y'.repeat(100) | ||
], function (assert, _data) { | ||
assert.true(true); | ||
}); | ||
|
||
QUnit.test.each('array of mixed', [ | ||
undefined, | ||
null, | ||
false, | ||
true, | ||
0, | ||
1, | ||
-10, | ||
10 / 3, | ||
10e42, | ||
Infinity, | ||
NaN, | ||
[], | ||
{}, | ||
'some' | ||
], function (assert, _value) { | ||
assert.true(true); | ||
}); | ||
|
||
QUnit.test.each('keyed objects', { caseFoo: [1, 2, 3], caseBar: [1, 1, 2] }, function (assert, _data) { | ||
assert.true(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# command: ["qunit", "each-array-labels.js"] | ||
|
||
TAP version 13 | ||
ok 1 array of arrays [0] | ||
ok 2 array of arrays [1] | ||
ok 3 array of strings [foo] | ||
ok 4 array of strings [] | ||
ok 5 array of strings [ ] | ||
ok 6 array of strings [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] | ||
ok 7 array of strings [$] | ||
ok 8 array of strings [http://example.org] | ||
ok 9 array of strings [6: 999: example] | ||
ok 10 array of strings [7] | ||
ok 11 array of strings [8] | ||
ok 12 array of strings [9: yyyyyyyyyyyyyyyyyyyyyyyyyyyyy…] | ||
ok 13 array of mixed [0: undefined] | ||
ok 14 array of mixed [1: null] | ||
ok 15 array of mixed [2: false] | ||
ok 16 array of mixed [3: true] | ||
ok 17 array of mixed [4: 0] | ||
ok 18 array of mixed [5: 1] | ||
ok 19 array of mixed [6: -10] | ||
ok 20 array of mixed [7: 3.3333333333333335] | ||
ok 21 array of mixed [8: 1e+43] | ||
ok 22 array of mixed [9: Infinity] | ||
ok 23 array of mixed [10: NaN] | ||
ok 24 array of mixed [11] | ||
ok 25 array of mixed [12] | ||
ok 26 array of mixed [some] | ||
ok 27 keyed objects [caseFoo] | ||
ok 28 keyed objects [caseBar] | ||
1..28 | ||
# pass 28 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters