diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 56 | ||||
| -rw-r--r-- | tests/unit_tests/completion_test.coffee | 8 | ||||
| -rw-r--r-- | tests/unit_tests/settings_test.coffee | 2 |
3 files changed, 7 insertions, 59 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 4afa9d7d..f81982ac 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -495,10 +495,6 @@ context "PostFindMode", testContent = "<input type='text' id='first'/>" document.getElementById("test-div").innerHTML = testContent document.getElementById("first").focus() - # For these tests, we need to push GrabBackFocus out of the way. When it exits, it updates the badge, - # which interferes with event suppression within insert mode. This cannot happen in normal operation, - # because GrabBackFocus exits on the first keydown. - Mode.top().exit() @postFindMode = new PostFindMode tearDown -> @@ -527,55 +523,3 @@ context "PostFindMode", sendKeyboardEvent "escape" assert.isTrue @postFindMode.modeIsActive -context "Mode badges", - setup -> - initializeModeState() - testContent = "<input type='text' id='first'/>" - document.getElementById("test-div").innerHTML = testContent - - tearDown -> - document.getElementById("test-div").innerHTML = "" - - should "have no badge in normal mode", -> - Mode.updateBadge() - assert.isTrue chromeMessages[0].badge == "" - - should "have an I badge in insert mode by focus", -> - document.getElementById("first").focus() - # Focus triggers an event in the handler stack, so we check element "1", here. - assert.isTrue chromeMessages[1].badge == "I" - - should "have no badge after leaving insert mode by focus", -> - document.getElementById("first").focus() - document.getElementById("first").blur() - assert.isTrue chromeMessages[0].badge == "" - - should "have an I badge in global insert mode", -> - new InsertMode global: true - assert.isTrue chromeMessages[0].badge == "I" - - should "have no badge after leaving global insert mode", -> - mode = new InsertMode global: true - mode.exit() - assert.isTrue chromeMessages[0].badge == "" - - should "have a ? badge in PostFindMode (immediately)", -> - document.getElementById("first").focus() - new PostFindMode - assert.isTrue chromeMessages[0].badge == "?" - - should "have no badge in PostFindMode (subsequently)", -> - document.getElementById("first").focus() - new PostFindMode - sendKeyboardEvent "a" - assert.isTrue chromeMessages[0].badge == "" - - should "have no badge when disabled", -> - handlerStack.bubbleEvent "registerStateChange", - enabled: false - passKeys: "" - - document.getElementById("first").focus() - # Focus triggers an event in the handler stack, so we check element "1", here. - assert.isTrue chromeMessages[1].badge == "" - diff --git a/tests/unit_tests/completion_test.coffee b/tests/unit_tests/completion_test.coffee index b7b73cc2..56fcc456 100644 --- a/tests/unit_tests/completion_test.coffee +++ b/tests/unit_tests/completion_test.coffee @@ -152,8 +152,9 @@ context "domain completer", setup -> @history1 = { title: "history1", url: "http://history1.com", lastVisitTime: hours(1) } @history2 = { title: "history2", url: "http://history2.com", lastVisitTime: hours(1) } + @undef = { title: "history2", url: "http://undefined.net", lastVisitTime: hours(1) } - stub(HistoryCache, "use", (onComplete) => onComplete([@history1, @history2])) + stub(HistoryCache, "use", (onComplete) => onComplete([@history1, @history2, @undef])) global.chrome.history = onVisited: { addListener: -> } onVisitRemoved: { addListener: -> } @@ -174,6 +175,9 @@ context "domain completer", should "returns no results when there's more than one query term, because clearly it's not a domain", -> assert.arrayEqual [], filterCompleter(@completer, ["his", "tory"]) + should "not return any results for empty queries", -> + assert.arrayEqual [], filterCompleter(@completer, []) + context "domain completer (removing entries)", setup -> @history1 = { title: "history1", url: "http://history1.com", lastVisitTime: hours(2) } @@ -238,7 +242,7 @@ context "search engines", @completer = new SearchEngineCompleter() # note, I couldn't just call @completer.refresh() here as I couldn't set root.Settings without errors # workaround is below, would be good for someone that understands the testing system better than me to improve - @completer.searchEngines = Settings.getSearchEngines() + @completer.searchEngines = SearchEngineCompleter.getSearchEngines() should "return search engine suggestion without description", -> results = filterCompleter(@completer, ["foo", "hello"]) diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee index afe862a4..346c98da 100644 --- a/tests/unit_tests/settings_test.coffee +++ b/tests/unit_tests/settings_test.coffee @@ -73,7 +73,7 @@ context "settings", should "set search engines, retrieve them correctly and check that they have been parsed correctly", -> searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s baz description" Settings.set 'searchEngines', searchEngines - result = Settings.getSearchEngines() + result = SearchEngineCompleter.getSearchEngines() assert.equal Object.keys(result).length, 2 assert.equal "bar?q=%s", result["foo"].url assert.isFalse result["foo"].description |
