/
item-test.js
73 lines (51 loc) · 1.98 KB
/
item-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
import { render, click } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";
module("Integration | Component | uk tab/item", function (hooks) {
setupRenderingTest(hooks);
test("renders", async function (assert) {
await render(hbs`<UkTab::Item>Test</UkTab::Item>`);
assert.dom("li").exists();
assert.dom("a").exists();
assert.dom("a").hasText("Test");
});
test("can be active", async function (assert) {
await render(hbs`<UkTab::Item @active={{true}}>Test</UkTab::Item>`);
assert.dom("li").hasClass("uk-active");
});
test("can be disabled", async function (assert) {
await render(hbs`<UkTab::Item @disabled={{true}}>Test</UkTab::Item>`);
assert.dom("li").hasClass("uk-disabled");
});
test("can be clicked", async function (assert) {
this.click = () => assert.step("click");
await render(hbs`<UkTab::Item @onClick={{this.click}}>Test</UkTab::Item>`);
await click("a");
assert.verifySteps(["click"]);
});
test("can navigate via href", async function (assert) {
assert.expect(4);
this.owner.lookup("service:router").transitionTo = (href) => {
assert.step("navigate");
assert.strictEqual(href, "/");
};
await render(hbs`<UkTab::Item @href="/">Test</UkTab::Item>`);
assert.dom("a").hasAttribute("href", "/");
await click("a");
assert.verifySteps(["navigate"]);
});
test("yields the active state", async function (assert) {
assert.expect(2);
this.owner.lookup("service:router").isActive = () => false;
await render(
hbs`<UkTab::Item @href="/" as |active|>{{unless active "not "}}active</UkTab::Item>`
);
assert.dom("a").hasText("not active");
this.owner.lookup("service:router").isActive = () => true;
await render(
hbs`<UkTab::Item @href="/" as |active|>{{unless active "not "}}active</UkTab::Item>`
);
assert.dom("a").hasText("active");
});
});