Rewrite some :follow-selected tests as unit tests

This commit is contained in:
Florian Bruhin 2018-09-08 16:01:38 +02:00
parent 45eece372f
commit 20da259de6
2 changed files with 22 additions and 25 deletions

View File

@ -45,31 +45,6 @@ Feature: Caret mode
# :follow-selected
Scenario: :follow-selected without a selection
When I run :follow-selected
Then no crash should happen
Scenario: :follow-selected with text
When I run :move-to-next-word
And I run :toggle-selection
And I run :move-to-end-of-word
And I run :follow-selected
Then no crash should happen
Scenario: :follow-selected with link (with JS)
When I set content.javascript.enabled to true
And I run :toggle-selection
And I run :move-to-end-of-word
And I run :follow-selected
Then data/hello.txt should be loaded
Scenario: :follow-selected with link (without JS)
When I set content.javascript.enabled to false
And I run :toggle-selection
And I run :move-to-end-of-word
And I run :follow-selected
Then data/hello.txt should be loaded
Scenario: :follow-selected with --tab (with JS)
When I set content.javascript.enabled to true
And I run :tab-only

View File

@ -315,3 +315,25 @@ class TestSearch:
caret.move_to_end_of_line()
selection.check('wei drei')
class TestFollowSelected:
def test_follow_selected_without_a_selection(self, caret, selection):
caret.follow_selected()
def test_follow_selected_with_text(self, caret, selection):
caret.move_to_next_word()
selection.toggle()
caret.move_to_end_of_word()
caret.follow_selected()
@pytest.mark.parametrize('with_js', [True, False])
def test_follow_selected_with_link(self, caret, selection, config_stub,
qtbot, web_tab, with_js):
config_stub.val.content.javascript.enabled = with_js
selection.toggle()
caret.move_to_end_of_word()
with qtbot.wait_signal(web_tab.load_finished):
caret.follow_selected()
assert web_tab.url().path() == '/data/hello.txt'