This adds acceptance tests for keyboard shortcuts to dismiss new and unread topics. Also, I cleaned out a few old specs for the unit test for keyboard-shortcuts. Some were introduced way back in5100c2bbd2but then supplanted by9548876c2dand never cleaned up, so they were doing nothing. Follow up to https://review.discourse.org/t/fix-dismiss-topics-keyboard-shortcut-not-working-pr-13260/22157/4?u=martin
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { module, test } from "qunit";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
|
import sinon from "sinon";
|
|
|
|
module("Unit | Utility | keyboard-shortcuts", function (hooks) {
|
|
hooks.beforeEach(function () {
|
|
sinon.stub(DiscourseURL, "routeTo");
|
|
});
|
|
|
|
test("selectDown calls _moveSelection with 1", function (assert) {
|
|
let stub = sinon.stub(KeyboardShortcuts, "_moveSelection");
|
|
|
|
KeyboardShortcuts.selectDown();
|
|
assert.ok(stub.calledWith(1), "_moveSelection is called with 1");
|
|
});
|
|
|
|
test("selectUp calls _moveSelection with -1", function (assert) {
|
|
let stub = sinon.stub(KeyboardShortcuts, "_moveSelection");
|
|
|
|
KeyboardShortcuts.selectUp();
|
|
assert.ok(stub.calledWith(-1), "_moveSelection is called with -1");
|
|
});
|
|
|
|
test("goBack calls history.back", function (assert) {
|
|
let called = false;
|
|
sinon.stub(history, "back").callsFake(function () {
|
|
called = true;
|
|
});
|
|
|
|
KeyboardShortcuts.goBack();
|
|
assert.ok(called, "history.back is called");
|
|
});
|
|
|
|
test("nextSection calls _changeSection with 1", function (assert) {
|
|
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
|
|
|
|
KeyboardShortcuts.nextSection();
|
|
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
|
|
});
|
|
|
|
test("prevSection calls _changeSection with -1", function (assert) {
|
|
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
|
|
|
|
KeyboardShortcuts.prevSection();
|
|
assert.ok(spy.calledWith(-1), "_changeSection is called with -1");
|
|
});
|
|
});
|