Sha256: 7f0fcbb3d06b6be2ac6ea1edb11cd266529036e13f3d6db92ac1fa4d5609219d

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

import { subscribe, reset } from '@ember/instrumentation';
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';

moduleFor(
  'View Instrumentation',
  class extends ApplicationTestCase {
    constructor() {
      super();
      this.addTemplate('application', `{{outlet}}`);
      this.addTemplate('index', `<h1>Index</h1>`);
      this.addTemplate('posts', `<h1>Posts</h1>`);

      this.router.map(function() {
        this.route('posts');
      });
    }
    teardown() {
      reset();
      super.teardown();
    }

    ['@test Nodes without view instances are instrumented'](assert) {
      let called = false;

      subscribe('render', {
        before() {
          called = true;
        },
        after() {},
      });

      return this.visit('/')
        .then(() => {
          assert.equal(this.textValue(), 'Index', 'It rendered the correct template');

          assert.ok(called, 'Instrumentation called on first render');
          called = false;

          return this.visit('/posts');
        })
        .then(() => {
          assert.equal(this.textValue(), 'Posts', 'It rendered the correct template');
          assert.ok(called, 'Instrumentation called on transition to non-view backed route');
        });
    }
  }
);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/ember/tests/view_instrumentation_test.js
discourse-ember-source-3.5.1.1 dist/es/ember/tests/view_instrumentation_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember/tests/view_instrumentation_test.js