From 51fa63a5e97167b015acf7b80d673d081c2b91da Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Tue, 24 Oct 2017 18:36:23 +0100
Subject: Move NormalMode to its own content script
---
tests/dom_tests/dom_tests.html | 1 +
1 file changed, 1 insertion(+)
(limited to 'tests')
diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html
index d2e795d1..37cd43e3 100644
--- a/tests/dom_tests/dom_tests.html
+++ b/tests/dom_tests/dom_tests.html
@@ -49,6 +49,7 @@
+
--
cgit v1.2.3
From 183858066bfb9b710056b2cb3330f08f22e09361 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Tue, 24 Oct 2017 20:37:04 +0100
Subject: Add tests to check that foreground commands are implemented
---
tests/unit_tests/commands_test.coffee | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
(limited to 'tests')
diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee
index 0e0be1d6..40afc1d7 100644
--- a/tests/unit_tests/commands_test.coffee
+++ b/tests/unit_tests/commands_test.coffee
@@ -3,6 +3,8 @@ extend global, require "./test_chrome_stubs.js"
extend global, require "../../background_scripts/bg_utils.js"
global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}
{Commands} = require "../../background_scripts/commands.js"
+global.KeyHandlerMode = {}
+{NormalModeCommands} = require "../../content_scripts/mode_normal.js"
context "Key mappings",
setup ->
@@ -114,6 +116,14 @@ context "Parse commands",
assert.equal "a", BgUtils.parseLines(" a \n b")[0]
assert.equal "b", BgUtils.parseLines(" a \n b")[1]
-# TODO (smblott) More tests:
-# - Ensure each background command has an implmentation in BackgroundCommands
-# - Ensure each foreground command has an implmentation in vimium_frontent.coffee
+context "Commands implemented",
+ (for own command, options of Commands.availableCommands
+ do (command, options) ->
+ if options.background
+ should "#{command} (background command)", ->
+ # TODO: Import background_scripts/main.js and expose BackgroundCommands from there.
+ # assert.isTrue BackgroundCommands[command]
+ else
+ should "#{command} (foreground command)", ->
+ assert.isTrue NormalModeCommands[command]
+ )...
--
cgit v1.2.3
From d8f8015f4cd71cf3681506a5ec16f00f8ab46f46 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Wed, 25 Oct 2017 00:34:43 +0100
Subject: Split focusInput, move the main part into the normal mode file
---
tests/unit_tests/commands_test.coffee | 1 +
1 file changed, 1 insertion(+)
(limited to 'tests')
diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee
index 40afc1d7..08bf0a73 100644
--- a/tests/unit_tests/commands_test.coffee
+++ b/tests/unit_tests/commands_test.coffee
@@ -4,6 +4,7 @@ extend global, require "../../background_scripts/bg_utils.js"
global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}
{Commands} = require "../../background_scripts/commands.js"
global.KeyHandlerMode = {}
+global.DomUtils = {makeXPath: ->}
{NormalModeCommands} = require "../../content_scripts/mode_normal.js"
context "Key mappings",
--
cgit v1.2.3
From b06ed7bd5cc82ec3307aeee945bcf6bf8f9264ce Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Wed, 25 Oct 2017 01:00:18 +0100
Subject: Include LinkHints, Vomnibar and Marks commands in normal mode file
---
tests/unit_tests/commands_test.coffee | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'tests')
diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee
index 08bf0a73..fcc7b821 100644
--- a/tests/unit_tests/commands_test.coffee
+++ b/tests/unit_tests/commands_test.coffee
@@ -3,8 +3,14 @@ extend global, require "./test_chrome_stubs.js"
extend global, require "../../background_scripts/bg_utils.js"
global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}
{Commands} = require "../../background_scripts/commands.js"
-global.KeyHandlerMode = {}
+
+# Include mode_normal to check that all commands have been implemented.
+global.KeyHandlerMode = global.Mode = {}
global.DomUtils = {makeXPath: ->}
+global.KeyboardUtils = {platform: ""}
+extend global, require "../../content_scripts/link_hints.js"
+extend global, require "../../content_scripts/marks.js"
+extend global, require "../../content_scripts/vomnibar.js"
{NormalModeCommands} = require "../../content_scripts/mode_normal.js"
context "Key mappings",
--
cgit v1.2.3
From f65720e58e31a0218e0c176a9140520451e5dd7d Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Sat, 28 Oct 2017 17:04:37 +0100
Subject: Remove invokeCommandString, call NormalModeCommands directly
---
tests/unit_tests/utils_test.coffee | 20 --------------------
1 file changed, 20 deletions(-)
(limited to 'tests')
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index cc1081dd..2794a6d7 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -138,26 +138,6 @@ context "distinctCharacters",
should "eliminate duplicate characters", ->
assert.equal "abc", Utils.distinctCharacters "bbabaabbacabbbab"
-context "invokeCommandString",
- setup ->
- @beenCalled = false
- window.singleComponentCommand = => @beenCalled = true
- window.twoComponentCommand = command: window.singleComponentCommand
-
- tearDown ->
- delete window.singleComponentCommand
- delete window.twoComponentCommand
-
- should "invoke single-component commands", ->
- assert.isFalse @beenCalled
- Utils.invokeCommandString "singleComponentCommand"
- assert.isTrue @beenCalled
-
- should "invoke multi-component commands", ->
- assert.isFalse @beenCalled
- Utils.invokeCommandString "twoComponentCommand.command"
- assert.isTrue @beenCalled
-
context "escapeRegexSpecialCharacters",
should "escape regexp special characters", ->
str = "-[]/{}()*+?.^$|"
--
cgit v1.2.3
From 9847144f3493547af7eb419f11552ac18d7e9872 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Sat, 28 Oct 2017 17:09:24 +0100
Subject: Remove normal mode commands from global scope
---
tests/dom_tests/dom_tests.coffee | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
(limited to 'tests')
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index a5c85606..6e422d46 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -436,29 +436,29 @@ context "Input focus",
document.getElementById("test-div").innerHTML = ""
should "focus the first element", ->
- focusInput 1
+ NormalModeCommands.focusInput 1
assert.equal "first", document.activeElement.id
should "focus the nth element", ->
- focusInput 100
+ NormalModeCommands.focusInput 100
assert.equal "third", document.activeElement.id
should "activate insert mode on the first element", ->
- focusInput 1
+ NormalModeCommands.focusInput 1
assert.isTrue InsertMode.permanentInstance.isActive()
should "activate insert mode on the first element", ->
- focusInput 100
+ NormalModeCommands.focusInput 100
assert.isTrue InsertMode.permanentInstance.isActive()
should "activate the most recently-selected input if the count is 1", ->
- focusInput 3
- focusInput 1
+ NormalModeCommands.focusInput 3
+ NormalModeCommands.focusInput 1
assert.equal "third", document.activeElement.id
should "not trigger insert if there are no inputs", ->
document.getElementById("test-div").innerHTML = ""
- focusInput 1
+ NormalModeCommands.focusInput 1
assert.isFalse InsertMode.permanentInstance.isActive()
# TODO: these find prev/next link tests could be refactored into unit tests which invoke a function which has
@@ -479,7 +479,7 @@ context "Find prev / next links",
next page
"""
stubSettings "nextPatterns", "next"
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#second', window.location.hash
should "match against non-word patterns", ->
@@ -487,7 +487,7 @@ context "Find prev / next links",
>>
"""
stubSettings "nextPatterns", ">>"
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#first', window.location.hash
should "favor matches with fewer words", ->
@@ -496,14 +496,14 @@ context "Find prev / next links",
next!
"""
stubSettings "nextPatterns", "next"
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#second', window.location.hash
should "find link relation in header", ->
document.getElementById("test-div").innerHTML = """
"""
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#first', window.location.hash
should "favor link relation to text matching", ->
@@ -511,14 +511,14 @@ context "Find prev / next links",
next
"""
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#first', window.location.hash
should "match mixed case link relation", ->
document.getElementById("test-div").innerHTML = """
"""
- goNext()
+ NormalModeCommands.goNext()
assert.equal '#first', window.location.hash
createLinks = (n) ->
--
cgit v1.2.3
From 24148c709806d1631f35cd8efd3fdec4f2376f92 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Sun, 29 Oct 2017 12:51:53 +0000
Subject: Guard against undefined DomUtils, instead of stubbing in tests
---
tests/unit_tests/commands_test.coffee | 1 -
1 file changed, 1 deletion(-)
(limited to 'tests')
diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee
index fcc7b821..49dd2570 100644
--- a/tests/unit_tests/commands_test.coffee
+++ b/tests/unit_tests/commands_test.coffee
@@ -6,7 +6,6 @@ global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}
# Include mode_normal to check that all commands have been implemented.
global.KeyHandlerMode = global.Mode = {}
-global.DomUtils = {makeXPath: ->}
global.KeyboardUtils = {platform: ""}
extend global, require "../../content_scripts/link_hints.js"
extend global, require "../../content_scripts/marks.js"
--
cgit v1.2.3