summaryrefslogtreecommitdiff
path: root/tests/unit/completion/test_models.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-07-29 20:18:23 +0200
committerFlorian Bruhin <me@the-compiler.org>2020-07-29 20:53:30 +0200
commitf42cc99595d97ce14ac6a8c530b13f176ae2faee (patch)
treebf92272944fc21b51ff9368da7fde0868aa34319 /tests/unit/completion/test_models.py
parent63b44c17ac662d194dbf9d5c863593dd10b39df5 (diff)
downloadqutebrowser-f42cc99595d97ce14ac6a8c530b13f176ae2faee.tar.gz
qutebrowser-f42cc99595d97ce14ac6a8c530b13f176ae2faee.zip
Add completion for :undo
See #32
Diffstat (limited to 'tests/unit/completion/test_models.py')
-rw-r--r--tests/unit/completion/test_models.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index 1c2d94f08..f105d2b8a 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -40,6 +40,7 @@ from qutebrowser.completion import completer
from qutebrowser.completion.models import miscmodels, urlmodel, configmodel
from qutebrowser.config import configdata, configtypes
from qutebrowser.utils import usertypes
+from qutebrowser.mainwindow import tabbedbrowser
def _check_completions(model, expected):
@@ -1263,3 +1264,31 @@ def test_forward_completion(tab_with_history, info):
("4", "http://example.com/thing4", "thing4 detail"),
],
})
+
+
+def test_undo_completion(tabbed_browser_stubs, info):
+ """Test :undo completion."""
+ entry1 = tabbedbrowser._UndoEntry(url=QUrl('https://example.org/'),
+ history=None, index=None, pinned=None)
+ entry2 = tabbedbrowser._UndoEntry(url=QUrl('https://example.com/'),
+ history=None, index=None, pinned=None)
+ entry3 = tabbedbrowser._UndoEntry(url=QUrl('https://example.net/'),
+ history=None, index=None, pinned=None)
+
+ # Most recently closed is at the end
+ tabbed_browser_stubs[0].undo_stack = [
+ [entry1],
+ [entry2, entry3],
+ ]
+
+ model = miscmodels.undo(info=info)
+ model.set_pattern('')
+
+ # Most recently closed is at the top, indices are used like "-x" for the
+ # undo stack.
+ _check_completions(model, {
+ "Closed tabs": [
+ ("1", "https://example.com/, https://example.net/", None),
+ ("2", "https://example.org/", None),
+ ],
+ })