-
-
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 #16902 from smfoote/tracked-tests
Tracked tests
- Loading branch information
Showing
5 changed files
with
100 additions
and
100 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 was deleted.
Oops, something went wrong.
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,65 @@ | ||
import { AbstractTestCase, moduleFor } from 'internal-test-helpers'; | ||
import { get, set, setHasViews, tracked } from '../..'; | ||
|
||
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features'; | ||
|
||
if (EMBER_METAL_TRACKED_PROPERTIES) { | ||
const createObj = () => { | ||
class Obj { | ||
@tracked string = 'string'; | ||
@tracked number = 23; | ||
@tracked boolTrue = true; | ||
@tracked boolFalse = false; | ||
@tracked nullValue = null; | ||
@tracked undefinedValue = undefined; | ||
constructor() { | ||
this.string = 'string'; | ||
this.number = 23; | ||
this.boolTrue = true; | ||
this.boolFalse = false; | ||
this.nullValue = null; | ||
this.undefinedValue = undefined; | ||
} | ||
} | ||
|
||
return new Obj(); | ||
}; | ||
|
||
moduleFor( | ||
'@tracked set', | ||
class extends AbstractTestCase { | ||
teardown() { | ||
setHasViews(() => false); | ||
} | ||
|
||
['@test should set arbitrary properties on an object'](assert) { | ||
let obj = createObj(); | ||
|
||
let newObj = new class { | ||
@tracked undefinedValue = 'emberjs'; | ||
|
||
constructor() { | ||
this.undefinedValue = 'emberjs'; | ||
} | ||
}(); | ||
|
||
for (let key in obj) { | ||
assert.equal(set(newObj, key, obj[key]), obj[key], 'should return value'); | ||
assert.equal(get(newObj, key), obj[key], 'should set value'); | ||
} | ||
} | ||
|
||
['@test should set a number key on an object'](assert) { | ||
let obj = new class { | ||
@tracked 1 = 'original'; | ||
constructor() { | ||
this[1] = 'original'; | ||
} | ||
}(); | ||
|
||
set(obj, '1', 'first'); | ||
assert.equal(obj[1], 'first'); | ||
} | ||
} | ||
); | ||
} |
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