/*jshint multistr:true*/
var appModule = require('./helpers/app-module');
var assertHTMLMatches = require('./helpers/assert-html-matches');
appModule('App Boot');
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.template(
'components/root-component',
"\
Hello {{#if hasExistence}}{{location}}{{/if}}
\
{{component 'foo-bar'}}
\
"
);
this.component('root-component', {
location: 'World',
hasExistence: true,
});
this.template('components/foo-bar', '\
The files are *inside* the computer?!
\
');
return this.renderToHTML('/').then(function(html) {
assertHTMLMatches(
assert,
html,
'Hello World
The files are *inside* the computer?!
'
);
});
});
QUnit.test('{{link-to}}', function(assert) {
this.template('application', "{{#link-to 'photos'}}Go to photos{{/link-to}}
");
this.routes(function() {
this.route('photos');
});
return this.renderToHTML('/').then(function(html) {
assertHTMLMatches(
assert,
html,
''
);
});
});
QUnit.test('non-escaped content', function(assert) {
this.routes(function() {
this.route('photos');
});
this.template('application', '{{{title}}}
');
this.controller('application', {
title: 'Hello world',
});
return this.renderToHTML('/').then(function(html) {
assertHTMLMatches(
assert,
html,
'Hello world
'
);
});
});
QUnit.test('outlets', function(assert) {
this.routes(function() {
this.route('photos');
});
this.template('application', '{{outlet}}
');
this.template('index', 'index');
this.template('photos', 'photos');
var promises = [];
promises.push(
this.renderToHTML('/').then(function(html) {
assertHTMLMatches(
assert,
html,
''
);
})
);
promises.push(
this.renderToHTML('/photos').then(function(html) {
assertHTMLMatches(
assert,
html,
''
);
})
);
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', "");
return this.renderToHTML('/').then(function(html) {
assertHTMLMatches(
assert,
html,
''
);
});
});