-
-
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 #16919 from pzuraq/add-initializing-flag-to-meta
[refactor] Adds initialization flag and isPrototypeMeta()
- Loading branch information
Showing
8 changed files
with
129 additions
and
35 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
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
67 changes: 67 additions & 0 deletions
67
packages/@ember/-internals/metal/tests/property_events_test.js
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,67 @@ | ||
import { meta } from '@ember/-internals/meta'; | ||
import { notifyPropertyChange, PROPERTY_DID_CHANGE } from '..'; | ||
import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; | ||
|
||
moduleFor( | ||
'notifyPropertyChange', | ||
class extends AbstractTestCase { | ||
['@test notifies property changes on instances'](assert) { | ||
class Foo { | ||
[PROPERTY_DID_CHANGE](prop) { | ||
assert.equal(prop, 'bar', 'property change notified'); | ||
} | ||
} | ||
|
||
let foo = new Foo(); | ||
|
||
notifyPropertyChange(foo, 'bar'); | ||
} | ||
|
||
['@test notifies property changes on instances with meta'](assert) { | ||
class Foo { | ||
[PROPERTY_DID_CHANGE](prop) { | ||
assert.equal(prop, 'bar', 'property change notified'); | ||
} | ||
} | ||
|
||
let foo = new Foo(); | ||
|
||
meta(foo); // setup meta | ||
|
||
notifyPropertyChange(foo, 'bar'); | ||
} | ||
|
||
['@test does not notify on class prototypes with meta'](assert) { | ||
assert.expect(0); | ||
|
||
class Foo { | ||
[PROPERTY_DID_CHANGE](prop) { | ||
assert.equal(prop, 'bar', 'property change notified'); | ||
} | ||
} | ||
|
||
let foo = new Foo(); | ||
|
||
meta(foo.constructor.prototype); // setup meta for prototype | ||
|
||
notifyPropertyChange(foo.constructor.prototype, 'bar'); | ||
} | ||
|
||
['@test does not notify on non-class prototypes with meta'](assert) { | ||
assert.expect(0); | ||
|
||
let foo = { | ||
[PROPERTY_DID_CHANGE](prop) { | ||
assert.equal(prop, 'baz', 'property change notified'); | ||
}, | ||
}; | ||
|
||
let bar = Object.create(foo); | ||
|
||
meta(foo); // setup meta for prototype | ||
meta(bar); // setup meta for instance, switch prototype | ||
|
||
notifyPropertyChange(foo, 'baz'); | ||
} | ||
} | ||
); |
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