-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18477 from emberjs/bugfix/allow-each-towork-with-…
…falsy-values [BUGFIX release] Allows @each to work with arrays that contain falsy …
- Loading branch information
Showing
2 changed files
with
29 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,6 +457,28 @@ moduleFor( | |
assert.deepEqual(n.normalized, []); | ||
} | ||
|
||
['@test @each works on array with falsy values'](assert) { | ||
let obj = EmberObject.extend({ | ||
falsy: [null, undefined, false, '', 0, {}], | ||
truthy: [true, 'foo', 123], | ||
|
||
falsyComputed: computed('[email protected]', () => { | ||
assert.ok(true, 'falsy computed'); | ||
}), | ||
|
||
truthyComputed: computed('[email protected]', () => { | ||
assert.ok(true, 'truthy computed'); | ||
}), | ||
}).create(); | ||
|
||
// should throw no errors | ||
obj.falsyComputed; | ||
|
||
expectAssertion(() => { | ||
obj.truthyComputed; | ||
}, /When using @each to observe the array `true,foo,123`, the items in the array must be objects/); | ||
} | ||
|
||
['@test @each works with array-likes'](assert) { | ||
class ArrayLike { | ||
constructor(arr = []) { | ||
|