-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathsetup-rendering-test-test.js
54 lines (41 loc) · 1.58 KB
/
setup-rendering-test-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
import { module, test } from 'qunit';
import Component from '@ember/component';
import { helper } from '@ember/component/helper';
import hbs from 'htmlbars-inline-precompile';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { setResolverRegistry } from '../helpers/resolver';
import hasEmberVersion from 'ember-test-helpers/has-ember-version';
module('setupRenderingTest tests', function(hooks) {
if (!hasEmberVersion(2, 4)) {
return;
}
hooks.beforeEach(function() {
setResolverRegistry({});
});
setupRenderingTest(hooks);
test('can render a simple template', async function(assert) {
await render(hbs`<p>Hello!</p>`);
assert.equal(this.element.textContent, 'Hello!');
});
test('can invoke template only components', async function(assert) {
this.owner.register('template:components/template-only', hbs`template-only component here`);
await render(hbs`{{template-only}}`);
assert.equal(this.element.textContent, 'template-only component here');
});
test('can invoke JS only components', async function(assert) {
this.owner.register(
'component:js-only',
Component.extend({
classNames: ['js-only'],
})
);
await render(hbs`{{js-only}}`);
assert.ok(this.element.querySelector('.js-only'), 'element found for js-only component');
});
test('can invoke helper', async function(assert) {
this.owner.register('helper:jax', helper(([name]) => `${name}-jax`));
await render(hbs`{{jax "max"}}`);
assert.equal(this.element.textContent, 'max-jax');
});
});