Sha256: 5d0c1f7728c1bfbdd94d02e8b2992080c39a7ff8a6a1f52469f06fb4be70cba0

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

import { OWNER, getOwner } from 'ember-owner';
import { Container, Registry } from 'container';
import ContainerProxy from '../../lib/mixins/container_proxy';
import EmberObject from '../../lib/system/object';
import { run, schedule } from '@ember/runloop';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor(
  'ember-runtime/mixins/container_proxy',
  class extends AbstractTestCase {
    beforeEach() {
      this.Owner = EmberObject.extend(ContainerProxy);
      this.instance = this.Owner.create();

      this.registry = new Registry();

      this.instance.__container__ = new Container(this.registry, {
        owner: this.instance,
      });
    }

    ['@test provides ownerInjection helper method'](assert) {
      let result = this.instance.ownerInjection();

      assert.equal(result[OWNER], this.instance, 'returns an object with the OWNER symbol');
    }

    ['@test actions queue completes before destruction'](assert) {
      assert.expect(1);

      this.registry.register(
        'service:auth',
        EmberObject.extend({
          willDestroy() {
            assert.ok(getOwner(this).lookup('service:auth'), 'can still lookup');
          },
        })
      );

      let service = this.instance.lookup('service:auth');

      run(() => {
        schedule('actions', service, 'destroy');
        this.instance.destroy();
      });
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-runtime/tests/mixins/container_proxy_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-runtime/tests/mixins/container_proxy_test.js