diff options
Diffstat (limited to 'tests/dom_tests/dom_tests.coffee')
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 30 | 
1 files changed, 19 insertions, 11 deletions
| diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 8c2b73c3..e57f3eab 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -34,12 +34,20 @@ initializeModeState = ->    handlerStack.bubbleEvent "registerKeyQueue",      keyQueue: "" +# Tell Settings that it's been loaded. +Settings.isLoaded = true + +# Shoulda.js doesn't support async code, so we try not to use any. +Utils.nextTick = (func) -> func() +  #  # Retrieve the hint markers as an array object.  #  getHintMarkers = ->    Array::slice.call document.getElementsByClassName("vimiumHintMarker"), 0 +stubSettings = (key, value) -> stub Settings.cache, key, JSON.stringify value +  #  # Generate tests that are common to both default and filtered  # link hinting modes. @@ -52,8 +60,8 @@ createGeneralHintTests = (isFilteredMode) ->        initializeModeState()        testContent = "<a>test</a>" + "<a>tress</a>"        document.getElementById("test-div").innerHTML = testContent -      stub settings.values, "filterLinkHints", false -      stub settings.values, "linkHintCharacters", "ab" +      stubSettings "filterLinkHints", false +      stubSettings "linkHintCharacters", "ab"      tearDown ->        document.getElementById("test-div").innerHTML = "" @@ -92,8 +100,8 @@ context "Test link hints for focusing input elements correctly",      testDiv = document.getElementById("test-div")      testDiv.innerHTML = "" -    stub settings.values, "filterLinkHints", false -    stub settings.values, "linkHintCharacters", "ab" +    stubSettings "filterLinkHints", false +    stubSettings "linkHintCharacters", "ab"      # Every HTML5 input type except for hidden. We should be able to activate all of them with link hints.      inputTypes = ["button", "checkbox", "color", "date", "datetime", "datetime-local", "email", "file", @@ -129,8 +137,8 @@ context "Alphabetical link hints",    setup ->      initializeModeState() -    stub settings.values, "filterLinkHints", false -    stub settings.values, "linkHintCharacters", "ab" +    stubSettings "filterLinkHints", false +    stubSettings "linkHintCharacters", "ab"      # Three hints will trigger double hint chars.      createLinks 3 @@ -161,8 +169,8 @@ context "Filtered link hints",    # elements.    setup -> -    stub settings.values, "filterLinkHints", true -    stub settings.values, "linkHintNumbers", "0123456789" +    stubSettings "filterLinkHints", true +    stubSettings "linkHintNumbers", "0123456789"    context "Text hints", @@ -289,7 +297,7 @@ context "Find prev / next links",      <a href='#first'>nextcorrupted</a>      <a href='#second'>next page</a>      """ -    stub settings.values, "nextPatterns", "next" +    stubSettings "nextPatterns", "next"      goNext()      assert.equal '#second', window.location.hash @@ -297,7 +305,7 @@ context "Find prev / next links",      document.getElementById("test-div").innerHTML = """      <a href='#first'>>></a>      """ -    stub settings.values, "nextPatterns", ">>" +    stubSettings "nextPatterns", ">>"      goNext()      assert.equal '#first', window.location.hash @@ -306,7 +314,7 @@ context "Find prev / next links",      <a href='#first'>lorem ipsum next</a>      <a href='#second'>next!</a>      """ -    stub settings.values, "nextPatterns", "next" +    stubSettings "nextPatterns", "next"      goNext()      assert.equal '#second', window.location.hash | 
