/
link-to-test.js
89 lines (71 loc) · 3.08 KB
/
link-to-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
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { testBS3, testBS4 } from '../../../../helpers/bootstrap';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../../helpers/setup-no-deprecations';
module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});
testBS3('it has correct markup', async function (assert) {
// Template block usage:
await render(hbs`
{{#bs-dropdown/menu/link-to "index"}}
template block text
{{/bs-dropdown/menu/link-to}}
`);
assert.dom('*').hasText('template block text');
assert.dom('a.dropdown-item').doesNotExist('renders as plain element with no dropdown item class');
});
testBS4('it has correct markup', async function (assert) {
// Template block usage:
await render(hbs`
{{#bs-dropdown/menu/link-to "index"}}
template block text
{{/bs-dropdown/menu/link-to}}
`);
assert.dom('*').hasText('template block text');
assert.dom('a.dropdown-item').exists({ count: 1 }, 'renders as plain element with dropdown item class');
});
module('positional params', function () {
test('simple route link', async function (assert) {
await render(hbs`{{#bs-dropdown/menu/link-to "index"}}Link{{/bs-dropdown/menu/link-to}}`);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
test('link with model', async function (assert) {
await render(
hbs`{{#bs-dropdown/menu/link-to "acceptance.link" "1" (query-params foo="bar")}}Link{{/bs-dropdown/menu/link-to}}`
);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
test('disabled link', async function (assert) {
await render(hbs`{{#bs-dropdown/menu/link-to "index" disabled=true}}Link{{/bs-dropdown/menu/link-to}}`);
assert.dom('a').hasClass('disabled');
});
});
module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);
test('simple route link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index">Link</BsDropdown::menu::link-to>`);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
test('link with model', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsDropdown::menu::link-to>`
);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
test('disabled link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index" @disabled={{true}}>Link</BsDropdown::menu::link-to>`);
assert.dom('a').hasClass('disabled');
});
});
});