Use containerMenu as a base for HintMenu instead of regular menu
Change-Id: Ic1ed2e216a9c61aabf1f1cac41972b1a4e96a91a
diff --git a/dev/js/spec/hintSpec.js b/dev/js/spec/hintSpec.js
index 3e95e55..e81033d 100644
--- a/dev/js/spec/hintSpec.js
+++ b/dev/js/spec/hintSpec.js
@@ -272,7 +272,6 @@
hint.inputField().insert('der Baum corenlp/');
var cont = hint.inputField().container();
-
expect(cont.getElementsByTagName('div').length).toBe(1);
expect(cont.getElementsByTagName('ul').length).toBe(0);
expect(cont.firstChild).toEqual(cont.firstChild);
@@ -281,34 +280,34 @@
// There is a menu for corenlp/
hint.show(false);
- expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(1);
- expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(3);
+ expect(cont.getElementsByTagName('ul').length).toEqual(1+1); //+1 from containermenu (see container/container.js)
+ expect(cont.getElementsByTagName('li').length).toEqual(3);
// Hide the menu and focus on the input
hint.unshow();
- expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(1);
- expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(0);
+ expect(cont.getElementsByTagName('div').length).toEqual(1);
+ expect(cont.getElementsByTagName('li').length).toEqual(0);
hint.unshow();
hint.inputField().insert(' hhhh');
- // show with context
+ // show with context if possible
hint.show(false);
- expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(4);
- expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(1);
- expect(hint.inputField().container().getElementsByTagName('li').length).toEqual(2);
+ expect(cont.getElementsByTagName('div').length).toEqual(4);
+ expect(cont.getElementsByTagName('ul').length).toEqual(1+1);//+1 from containermenu (see container/container.js)
+ expect(cont.getElementsByTagName('li').length).toEqual(2);
hint.unshow();
hint.inputField().insert(' aaaa/');
- // show with context
+ // show with context necessarily
hint.show(true);
- expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(1);
- expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(0);
+ expect(cont.getElementsByTagName('div').length).toEqual(1);
+ expect(cont.getElementsByTagName('ul').length).toEqual(0); //here not +1: context doesnt fit
});
@@ -324,25 +323,25 @@
hint.show(false);
expect(hint.active()).toBeTruthy();
-
- expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.innerText).toEqual("Base Annotation");
+ var cont = hint.inputField().container();
+ expect(cont.getElementsByTagName('li')[0].firstChild.innerText).toEqual("Base Annotation");
// Type in prefix
hint.active().prefix("cor").show();
expect(hint.active().prefix()).toEqual("cor");
// Click first step
- expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.firstChild.innerText).toEqual("Cor");
- hint.inputField().container().getElementsByTagName('li')[0].click();
+ expect(cont.getElementsByTagName('li')[0].firstChild.firstChild.innerText).toEqual("Cor");
+ cont.getElementsByTagName('li')[0].click();
expect(hint.active()).toBeTruthy();
// Click second step
- expect(hint.inputField().container().getElementsByTagName('li')[0].firstChild.innerText).toEqual("Named Entity");
- hint.inputField().container().getElementsByTagName('li')[0].click()
+ expect(cont.getElementsByTagName('li')[0].firstChild.innerText).toEqual("Named Entity");
+ cont.getElementsByTagName('li')[0].click()
// Invisible menu
- expect(hint.inputField().container().getElementsByTagName('li')[0]).toBeUndefined();
+ expect(cont.getElementsByTagName('li')[0]).toBeUndefined();
// Inactive menu
expect(hint.active()).toBeFalsy();
@@ -420,10 +419,16 @@
// Type in prefix
hint.active().prefix("cor").show();
+ expect(hint.active()._prefix.value()).toBe("cor");
expect(hint.active().prefix()).toEqual("cor");
-
expect(input.value).toEqual("");
+ expect(hint.active()._prefix["isSelectable"]).not.toBeNull();
+ expect(hint._menuCollection['-']._prefix["isSelectable"]).not.toBeNull();
+ expect(hint.active()._prefix).toBe(hint._menuCollection['-']._prefix);
+ expect(hint.active()._prefix.element()).toBe(hint._menuCollection['-']._prefix.element());
hint.active()._prefix.element().click();
+
+
expect(input.value).toEqual("cor");
expect(hint.active()).toBeFalsy();
@@ -433,6 +438,7 @@
});
+
xit('should remove all menus on escape');
});