summaryrefslogtreecommitdiffstats
path: root/test/init/htmlSpec.js
diff options
context:
space:
mode:
authorLea Verou <lea@verou.me>2015-12-27 23:24:10 +0200
committerLea Verou <lea@verou.me>2015-12-27 23:24:10 +0200
commit9af4a6ef0b18901f893b116003271e4b718903f9 (patch)
treed727f656ad843bc67a3b0de83085d4862ad2dd0a /test/init/htmlSpec.js
parent2dae7fd9d23752abff4f230c060b4d625bb77031 (diff)
parentf9d6cca542c66aef3c550e65cef3940393dab88e (diff)
downloadawesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.zip
awesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.tar.gz
awesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.tar.bz2
Merge pull request #16785 from vlazar/features/improve-test-coverage
Improve test coverage
Diffstat (limited to 'test/init/htmlSpec.js')
-rw-r--r--test/init/htmlSpec.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/init/htmlSpec.js b/test/init/htmlSpec.js
new file mode 100644
index 0000000..3e0b9c1
--- /dev/null
+++ b/test/init/htmlSpec.js
@@ -0,0 +1,60 @@
+describe("Html modifications", function () {
+
+ $.fixture("plain");
+
+ subject(function () { return new Awesomplete("#plain") });
+
+ it("binds to correct input", function () {
+ expect(this.subject.input instanceof HTMLElement).toBe(true);
+ expect(this.subject.input.id).toBe("plain");
+ });
+
+ it("turns native autocompleter off", function () {
+ expect(this.subject.input.getAttribute("autocomplete")).toBe("off");
+ });
+
+ describe("HTML tweaks", function () {
+ it("creates container", function () {
+ expect(this.subject.container instanceof HTMLElement).toBe(true);
+ expect(this.subject.container.className).toBe("awesomplete");
+ });
+
+ it("places input inside container", function () {
+ expect(this.subject.input.parentNode).toBe(this.subject.container);
+ });
+
+ it("creates list", function () {
+ expect(this.subject.ul instanceof HTMLElement).toBe(true);
+ expect(this.subject.ul.tagName).toBe("UL");
+ });
+
+ it("places list inside container", function () {
+ expect(this.subject.ul.parentNode).toBe(this.subject.container);
+ });
+
+ it("hides list", function () {
+ expect(this.subject.ul.hasAttribute("hidden")).toBe(true);
+ });
+ });
+
+ describe("ARIA support", function () {
+ it("makes input accessible", function () {
+ expect(this.subject.input.getAttribute("aria-autocomplete")).toBe("list");
+ });
+
+ it("creates status", function () {
+ expect(this.subject.status instanceof HTMLElement).toBe(true);
+ expect(this.subject.status.getAttribute("role")).toBe("status");
+ expect(this.subject.status.getAttribute("aria-live")).toBe("assertive");
+ expect(this.subject.status.getAttribute("aria-relevant")).toBe("additions");
+ });
+
+ it("puts status inside container", function () {
+ expect(this.subject.status.parentNode).toBe(this.subject.container);
+ });
+
+ it("hides status", function () {
+ expect(this.subject.status.className).toBe("visually-hidden");
+ });
+ });
+});