summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/awesompleteShared.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/awesompleteShared.js b/test/awesompleteShared.js
new file mode 100644
index 0000000..64d53f4
--- /dev/null
+++ b/test/awesompleteShared.js
@@ -0,0 +1,45 @@
+var shared = {
+ expectMinCharsToBe: function(num){
+ return function(){
+ expect(shared.awesompleter.minChars).toBe(num);
+ }
+ },
+ expectMaxItemsToBe: function(num){
+ return function(){
+ expect(shared.awesompleter.maxItems).toBe(num);
+ }
+ },
+ expectNumSuggestionsWith: function(num, val){
+ return function(){
+ shared.awesompleter.input.value = val;
+ shared.awesompleter.evaluate();
+ expect(shared.awesompleter.ul.children.length).toBe(num);
+ }
+ },
+ expectListLengthToBe: function(num){
+ return function(){
+ expect(shared.awesompleter._list.length).toBe(num);
+ }
+ },
+ expectSelectingFirstSuggestionToWorkWith: function(val){
+ return function(){
+ var li;
+ shared.awesompleter.input.value = val;
+ shared.awesompleter.evaluate();
+ li = shared.awesompleter.ul.children[0];
+ shared.awesompleter.select(li);
+ expect(shared.awesompleter.input.value).toBe(li.textContent);
+ }
+ },
+ expectAutoFirstToWorkWith: function(val){
+ return function(){
+ var li;
+ shared.awesompleter.input.value = val;
+ shared.awesompleter.evaluate();
+ shared.awesompleter.open();
+ li = shared.awesompleter.ul.children[0];
+ expect(li.getAttribute('aria-selected')).toBe('true');
+ expect(shared.awesompleter.status.textContent).toBe(li.textContent);
+ }
+ }
+};