-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
view_instrumentation_test.js
65 lines (56 loc) · 1.65 KB
/
view_instrumentation_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import run from 'ember-metal/run_loop';
import $ from 'ember-views/system/jquery';
import Application from 'ember-application/system/application';
import { subscribe, reset } from 'ember-metal/instrumentation';
import { compile } from 'ember-template-compiler/tests/utils/helpers';
import { setTemplates, set as setTemplate } from 'ember-templates/template_registry';
import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer';
var App, $fixture;
function setupExample() {
// setup templates
setTemplate('application', compile('{{outlet}}'));
setTemplate('index', compile('<h1>Node 1</h1>'));
setTemplate('posts', compile('<h1>Node 1</h1>'));
App.Router.map(function() {
this.route('posts');
});
}
function handleURL(path) {
var router = App.__container__.lookup('router:main');
return run(router, 'handleURL', path);
}
testModule('View Instrumentation', {
setup() {
run(function() {
App = Application.create({
rootElement: '#qunit-fixture'
});
App.deferReadiness();
App.Router.reopen({
location: 'none'
});
});
$fixture = $('#qunit-fixture');
setupExample();
},
teardown() {
reset();
run(App, 'destroy');
App = null;
setTemplates({});
}
});
test('Nodes without view instances are instrumented', function(assert) {
var called = false;
subscribe('render', {
before() {
called = true;
},
after() {}
});
run(App, 'advanceReadiness');
assert.ok(called, 'Instrumentation called on first render');
called = false;
handleURL('/posts');
assert.ok(called, 'instrumentation called on transition to non-view backed route');
});