diff options
author | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-01-30 14:56:00 +0300 |
---|---|---|
committer | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-01-30 14:56:00 +0300 |
commit | dd4db9083127c70e9e71822a9e75cdcf48e54601 (patch) | |
tree | 1ea93b704383233e0db3d523a5b133a298baff6d /test/static/itemSpec.js | |
parent | 0248c50f059becf8f2af5fa7ef2147678c94451a (diff) | |
parent | 35fe8c1f187c7a8f9627142bac63dcc4ad054bf4 (diff) | |
download | awesomplete-dd4db9083127c70e9e71822a9e75cdcf48e54601.zip awesomplete-dd4db9083127c70e9e71822a9e75cdcf48e54601.tar.gz awesomplete-dd4db9083127c70e9e71822a9e75cdcf48e54601.tar.bz2 |
Merge pull request #16834 from vlazar/feature/item-and-replace-tests
Tests for Awesomplete.ITEM and Awesomplete.REPLACE
Diffstat (limited to 'test/static/itemSpec.js')
-rw-r--r-- | test/static/itemSpec.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/static/itemSpec.js b/test/static/itemSpec.js new file mode 100644 index 0000000..95ae2a8 --- /dev/null +++ b/test/static/itemSpec.js @@ -0,0 +1,50 @@ +describe("Awesomplete.ITEM", function () { + + subject(function () { return Awesomplete.ITEM }); + + def("element", function () { return this.subject("JavaScript", this.input || "") }); + + it("creates DOM element", function () { + expect(this.element instanceof HTMLElement).toBe(true); + }); + + it("creates LI element", function () { + expect(this.element.tagName).toBe("LI"); + }); + + it("sets aria-selected to false", function () { + expect(this.element.getAttribute("aria-selected")).toBe("false"); + }); + + describe("with matched input", function () { + def("input", "jav"); + + it("marks the match", function () { + expect(this.element.innerHTML).toBe("<mark>Jav</mark>aScript"); + }); + }); + + describe("with multiple matches", function () { + def("input", "a"); + + it("marks all matches", function () { + expect(this.element.innerHTML).toBe("J<mark>a</mark>v<mark>a</mark>Script"); + }); + }); + + describe("with no match", function () { + def("input", "foo"); + + it("does not mark anything", function () { + expect(this.element.innerHTML).toBe("JavaScript"); + }); + }); + + describe("with empty input", function () { + def("input", ""); + + it("does not mark anything", function () { + expect(this.element.innerHTML).toBe("JavaScript"); + }); + }); +}); |