forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component_invocation_test.js
79 lines (64 loc) · 2.21 KB
/
component_invocation_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import compile from 'ember-template-compiler/system/compile';
import ComponentLookup from 'ember-views/component_lookup';
import Component from 'ember-views/components/component';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import buildOwner from 'container/tests/test-helpers/build-owner';
import { OWNER } from 'container/owner';
var owner, component;
function commonSetup() {
owner = buildOwner();
owner.registerOptionsForType('component', { singleton: false });
owner.registerOptionsForType('template', { instantiate: false });
owner.register('component-lookup:main', ComponentLookup);
}
function commonTeardown() {
runDestroy(owner);
runDestroy(component);
owner = component = null;
}
import isEnabled from 'ember-metal/features';
if (!isEnabled('ember-glimmer')) {
// jscs:disable
QUnit.module('component - invocation', {
setup() {
commonSetup();
},
teardown() {
commonTeardown();
}
});
QUnit.test('moduleName is available on _renderNode when a layout is present', function() {
expect(1);
var layoutModuleName = 'my-app-name/templates/components/sample-component';
var sampleComponentLayout = compile('Sample Component - {{yield}}', {
moduleName: layoutModuleName
});
owner.register('template:components/sample-component', sampleComponentLayout);
owner.register('component:sample-component', Component.extend({
didInsertElement: function() {
equal(this._renderNode.lastResult.template.meta.moduleName, layoutModuleName);
}
}));
component = Component.extend({
[OWNER]: owner,
layout: compile('{{sample-component}}')
}).create();
runAppend(component);
});
QUnit.test('moduleName is available on _renderNode when no layout is present', function() {
expect(1);
var templateModuleName = 'my-app-name/templates/application';
owner.register('component:sample-component', Component.extend({
didInsertElement: function() {
equal(this._renderNode.lastResult.template.meta.moduleName, templateModuleName);
}
}));
component = Component.extend({
[OWNER]: owner,
layout: compile('{{#sample-component}}Derp{{/sample-component}}', {
moduleName: templateModuleName
})
}).create();
runAppend(component);
});
}