diff options
| author | Jez Ng | 2012-10-29 17:34:51 -0400 | 
|---|---|---|
| committer | Jez Ng | 2012-10-29 17:35:37 -0400 | 
| commit | 0964cf83b338915f9c0e3e0b581e4995ba4fb742 (patch) | |
| tree | 6941da4d87c41b62194ab5a0249f238ac7dc8bb3 /tests/dom_tests/vomnibar_test.coffee | |
| parent | ba3f283e90c95d7b03e585098567606be1064937 (diff) | |
| download | vimium-0964cf83b338915f9c0e3e0b581e4995ba4fb742.tar.bz2 | |
More tests, because I like having coverage.
Diffstat (limited to 'tests/dom_tests/vomnibar_test.coffee')
| -rw-r--r-- | tests/dom_tests/vomnibar_test.coffee | 65 | 
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/dom_tests/vomnibar_test.coffee b/tests/dom_tests/vomnibar_test.coffee new file mode 100644 index 00000000..dc2a849f --- /dev/null +++ b/tests/dom_tests/vomnibar_test.coffee @@ -0,0 +1,65 @@ +context "Keep selection within bounds", + +  setup -> +    @completions = [] +    oldGetCompleter = Vomnibar.getCompleter.bind Vomnibar +    stub Vomnibar, 'getCompleter', (name) => +      completer = oldGetCompleter name +      stub completer, 'filter', (query, callback) => callback(@completions) +      completer + +  tearDown -> +    Vomnibar.vomnibarUI.hide() + +  should "set selection to position -1 for omni completion by default", -> +    Vomnibar.activate() +    ui = Vomnibar.vomnibarUI + +    @completions = [] +    ui.update(true) +    assert.equal -1, ui.selection + +    @completions = [{html:'foo',type:'tab',url:'http://example.com'}] +    ui.update(true) +    assert.equal -1, ui.selection + +    @completions = [] +    ui.update(true) +    assert.equal -1, ui.selection + +  should "set selection to position 0 for bookmark completion if possible", -> +    Vomnibar.activateBookmarks() +    ui = Vomnibar.vomnibarUI + +    @completions = [] +    ui.update(true) +    assert.equal -1, ui.selection + +    @completions = [{html:'foo',type:'bookmark',url:'http://example.com'}] +    ui.update(true) +    assert.equal 0, ui.selection + +    @completions = [] +    ui.update(true) +    assert.equal -1, ui.selection + +  should "keep selection within bounds", -> +    Vomnibar.activate() +    ui = Vomnibar.vomnibarUI + +    @completions = [] +    ui.update(true) + +    eventMock = +      preventDefault: -> +      stopPropagation: -> + +    @completions = [{html:'foo',type:'tab',url:'http://example.com'}] +    ui.update(true) +    stub ui, "actionFromKeyEvent", -> "down" +    ui.onKeydown eventMock +    assert.equal 0, ui.selection + +    @completions = [] +    ui.update(true) +    assert.equal -1, ui.selection  | 
