-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtag-icons-test.js
More file actions
82 lines (64 loc) · 2.65 KB
/
Copy pathtag-icons-test.js
File metadata and controls
82 lines (64 loc) · 2.65 KB
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
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import topicFixtures from "discourse/tests/fixtures/topic";
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
acceptance("Topic with tags", function (needs) {
needs.settings({ tagging_enabled: true, force_lowercase_tags: false });
const topicResponse = topicFixtures["/t/280/1.json"];
topicResponse.tags = ["tag1", "Tag2", "newsman"];
topicResponse.tags_descriptions = {
newsman: "newsman <a href='test'>link</a>",
};
test("Decorate topic title", async function (assert) {
await visit("/t/internationalization-localization/280");
assert.ok(queryAll(".title-wrapper .discourse-tags"), "it has tags");
assert.ok(
queryAll(".discourse-tags a.discourse-tag .tag-icon").length,
"it has tag icon"
);
const el = queryAll(".discourse-tags a.discourse-tag .tag-icon")[0];
assert.equal(
window.getComputedStyle(el).color,
"rgb(100, 100, 100)",
"tag icon color matches default value"
);
});
test("Tag icon exact matches only", async function (assert) {
settings.tag_icon_list = "news,question-circle|newsman,gear";
await visit("/t/internationalization-localization/280");
assert.ok(queryAll(".title-wrapper .discourse-tags"), "it has tags");
assert.ok(
queryAll(".discourse-tags a.discourse-tag .tag-icon").length,
"it has tag icon"
);
const el = queryAll(".discourse-tags a.discourse-tag .tag-icon .d-icon")[0];
assert.ok(el.classList.contains("d-icon-gear"), "tag matches correct icon");
assert
.dom(".discourse-tag[data-tag-name='newsman']")
.hasAttribute(
"title",
"newsman link",
"it has correct title without markup"
);
});
test("Tag uppercase matches", async function (assert) {
settings.tag_icon_list = "Tag2,star";
await visit("/t/internationalization-localization/280");
assert.ok(queryAll(".title-wrapper .discourse-tags"), "it has tags");
assert.ok(
queryAll(".discourse-tags a.discourse-tag .tag-icon").length,
"it has tag icon"
);
const el = queryAll(".discourse-tags a.discourse-tag .tag-icon .d-icon")[0];
assert.ok(el.classList.contains("d-icon-star"), "tag matches correct icon");
});
test("Ensure non-HEX colors do not throw an error", async function (assert) {
settings.tag_icon_list = "Tag2,star,rgba(0,0,0)";
await visit("/t/internationalization-localization/280");
assert.ok(queryAll(".title-wrapper .discourse-tags"), "it has tags");
assert.ok(
queryAll(".discourse-tags a.discourse-tag .tag-icon").length,
"it has tag icon"
);
});
});