-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
app-boot-test.js
147 lines (121 loc) · 3.94 KB
/
app-boot-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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const setupAppTest = require('./helpers/setup-app');
require('./helpers/assert-html-matches').register();
QUnit.module('App Boot', function (hooks) {
setupAppTest(hooks);
QUnit.test('App boots and routes to a URL', function (assert) {
this.visit('/');
assert.ok(this.app);
});
QUnit.test('nested {{component}}', function (assert) {
this.template('index', '{{root-component}}');
this.component(
'root-component',
{
location: 'World',
hasExistence: true,
},
"\
<h1>Hello {{#if this.hasExistence}}{{this.location}}{{/if}}</h1>\
<div>{{component 'foo-bar'}}</div>\
"
);
this.component(
'foo-bar',
undefined,
'\
<p>The files are *inside* the computer?!</p>\
'
);
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches(
html,
'<body><div id="EMBER_ID" class="ember-view"><h1>Hello World</h1><div><p>The files are *inside* the computer?!</p></div></div></body>'
);
});
});
QUnit.test('<LinkTo>', function (assert) {
this.template('application', "<h1><LinkTo @route='photos'>Go to photos</LinkTo></h1>");
this.routes(function () {
this.route('photos');
});
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches(
html,
'<body><h1><a id="EMBER_ID" href="/photos" class="ember-view">Go to photos</a></h1></body>'
);
});
});
QUnit.test('{{link-to}}', function (assert) {
this.template('application', "<h1>{{#link-to route='photos'}}Go to photos{{/link-to}}</h1>");
this.routes(function () {
this.route('photos');
});
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches(
html,
'<body><h1><a id="EMBER_ID" href="/photos" class="ember-view">Go to photos</a></h1></body>'
);
});
});
QUnit.test('non-escaped content', function (assert) {
this.routes(function () {
this.route('photos');
});
this.template('application', '<h1>{{{this.title}}}</h1>');
this.controller('application', {
title: '<b>Hello world</b>',
});
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches(html, '<body><h1><b>Hello world</b></h1></body>');
});
});
QUnit.test('outlets', function (assert) {
this.routes(function () {
this.route('photos');
});
this.template('application', '<p>{{outlet}}</p>');
this.template('index', '<span>index</span>');
this.template('photos', '<em>photos</em>');
let promises = [];
promises.push(
this.renderToHTML('/').then(function (html) {
assert.htmlMatches(html, '<body><p><span>index</span></p></body>');
})
);
promises.push(
this.renderToHTML('/photos').then(function (html) {
assert.htmlMatches(html, '<body><p><em>photos</em></p></body>');
})
);
return this.all(promises);
});
QUnit.test('lifecycle hooks disabled', function (assert) {
assert.expect(1);
this.template('application', "{{my-component foo='bar'}}{{outlet}}");
this.component('my-component', {
didReceiveAttrs() {
assert.ok(true, 'should trigger didReceiveAttrs hook');
},
willRender() {
assert.ok(false, 'should not trigger willRender hook');
},
didRender() {
assert.ok(false, 'should not trigger didRender hook');
},
willInsertElement() {
assert.ok(false, 'should not trigger willInsertElement hook');
},
didInsertElement() {
assert.ok(false, 'should not trigger didInsertElement hook');
},
});
return this.renderToHTML('/');
});
QUnit.test('Should not attempt to render element modifiers GH#14220', function (assert) {
assert.expect(1);
this.template('application', "<div {{action 'foo'}}></div>");
return this.renderToHTML('/').then(function (html) {
assert.htmlMatches(html, '<body><div></div></body>');
});
});
});