Skip to content

Commit 1b53ac0

Browse files
Robert Jacksonchancancode
authored andcommitted
[BUGFIX lts] Add test ensuring singletons instantiated during destruction are destroyed.
(cherry picked from commit 9378d8f) (cherry picked from commit a54eb57)
1 parent 97c3993 commit 1b53ac0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/@ember/-internals/container/tests/container_test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,28 @@ moduleFor(
736736
assert.deepEqual(Object.keys(instance), []);
737737
}
738738

739+
'@test instantiating via container.lookup during destruction enqueues destruction'(assert) {
740+
let registry = new Registry();
741+
let container = registry.container();
742+
let otherInstance;
743+
class Service extends factory() {
744+
destroy() {
745+
otherInstance = container.lookup('service:other');
746+
747+
assert.ok(otherInstance.isDestroyed, 'service:other was destroyed');
748+
}
749+
}
750+
registry.register('service:foo', Service);
751+
registry.register('service:other', factory());
752+
let instance = container.lookup('service:foo');
753+
assert.ok(instance, 'precond lookup successful');
754+
755+
runTask(() => {
756+
container.destroy();
757+
container.finalizeDestroy();
758+
});
759+
}
760+
739761
'@test instantiating via container.factoryFor().create() after destruction throws an error'(
740762
assert
741763
) {

0 commit comments

Comments
 (0)