summaryrefslogtreecommitdiffstats
path: root/test/api/evaluateSpec.js
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 13:58:30 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 15:42:46 +0300
commit132906cd69d43c45a4531f2e16a9bde6ef61c3ad (patch)
tree50da611c81d65bb931ff08a1f9c93717ecd41438 /test/api/evaluateSpec.js
parentca9c91a667da4b1a33d4542b57a5addec99fca89 (diff)
downloadawesomplete-132906cd69d43c45a4531f2e16a9bde6ef61c3ad.zip
awesomplete-132906cd69d43c45a4531f2e16a9bde6ef61c3ad.tar.gz
awesomplete-132906cd69d43c45a4531f2e16a9bde6ef61c3ad.tar.bz2
awesomplete.evaluate tests
Diffstat (limited to 'test/api/evaluateSpec.js')
-rw-r--r--test/api/evaluateSpec.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/api/evaluateSpec.js b/test/api/evaluateSpec.js
new file mode 100644
index 0000000..cc064b6
--- /dev/null
+++ b/test/api/evaluateSpec.js
@@ -0,0 +1,57 @@
+describe("awesomplete.evaluate", function () {
+
+ $.fixture("plain");
+
+ subject(function () {
+ return new Awesomplete("#plain", { list: ["item1", "item2", "item3"] });
+ });
+
+ describe("with too short input value", function () {
+ beforeEach(function () {
+ $.type(this.subject.input, "i");
+ });
+
+ it("closes completer", function () {
+ spyOn(this.subject, "close");
+ this.subject.evaluate();
+
+ expect(this.subject.close).toHaveBeenCalled();
+ });
+ });
+
+ describe("with no items found", function () {
+ beforeEach(function () {
+ $.type(this.subject.input, "nosuchitem");
+ });
+
+ it("closes completer", function () {
+ spyOn(this.subject, "close");
+ this.subject.evaluate();
+
+ expect(this.subject.close).toHaveBeenCalled();
+ });
+ });
+
+ describe("with some items found", function () {
+ beforeEach(function () {
+ $.type(this.subject.input, "ite");
+ });
+
+ it("opens completer", function () {
+ spyOn(this.subject, "open");
+ this.subject.evaluate();
+
+ expect(this.subject.open).toHaveBeenCalled();
+ });
+
+ it("fills completer with found items", function () {
+ this.subject.evaluate();
+ expect(this.subject.ul.children.length).toBe(3);
+ });
+
+ it("makes no item selected", function () {
+ this.subject.evaluate();
+ expect(this.subject.selected).toBe(false);
+ });
+ });
+});