bdd: Add some tests for :tab-move.

This commit is contained in:
Florian Bruhin 2015-11-26 18:37:47 +01:00
parent 3bcc80048d
commit 7f5e07d7cc
2 changed files with 89 additions and 1 deletions

View File

@ -892,7 +892,7 @@ class CommandDispatcher:
delta = 1 if count is None else count
if direction == '-':
new_idx = self._current_index() - delta
elif direction == '+':
elif direction == '+': # pragma: no branch
new_idx = self._current_index() + delta
else: # pragma: no cover
raise ValueError("Invalid direction '{}'!".format(direction))

View File

@ -317,3 +317,91 @@ Feature: Tab management
- data/numbers/1.txt
- data/numbers/2.txt (active)
- data/numbers/3.txt
# :tab-move
Scenario: :tab-move with absolute position.
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-move
Then the following tabs should be open:
- data/numbers/3.txt (active)
- data/numbers/1.txt
- data/numbers/2.txt
Scenario: :tab-move with absolute position and count.
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-move with count 2
Then the following tabs should be open:
- data/numbers/1.txt
- data/numbers/3.txt (active)
- data/numbers/2.txt
Scenario: :tab-move with absolute position and invalid count.
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-move with count 23
Then the error "Can't move tab to position 23!" should be shown.
And the following tabs should be open:
- data/numbers/1.txt
- data/numbers/2.txt
- data/numbers/3.txt (active)
Scenario: :tab-move with relative position (negative).
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-move -
Then the following tabs should be open:
- data/numbers/1.txt
- data/numbers/3.txt (active)
- data/numbers/2.txt
Scenario: :tab-move with relative position (positive).
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-focus 1
And I run :tab-move +
Then the following tabs should be open:
- data/numbers/2.txt
- data/numbers/1.txt (active)
- data/numbers/3.txt
Scenario: :tab-move with relative position (negative) and count.
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-move - with count 2
Then the following tabs should be open:
- data/numbers/3.txt (active)
- data/numbers/1.txt
- data/numbers/2.txt
Scenario: :tab-move with relative position and too big count.
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-focus 1
And I run :tab-move + with count 3
Then the error "Can't move tab to position 4!" should be shown
Scenario: Make sure :tab-move retains metadata
When I open data/title.html
And I open data/hello.txt in a new tab
And I run :tab-focus 1
And I run :tab-move +
Then the session should look like:
windows:
- tabs:
- history:
- url: http://localhost:*/data/hello.txt
- active: true
history:
- url: about:blank
- url: http://localhost:*/data/title.html
title: Test title