mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
DEV: introduces prettier for es6 files
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
|
||||
var testMouseTrap;
|
||||
import KeyboardShortcuts from 'discourse/lib/keyboard-shortcuts';
|
||||
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
||||
|
||||
QUnit.module("lib:keyboard-shortcuts", {
|
||||
beforeEach() {
|
||||
@ -15,8 +15,7 @@ QUnit.module("lib:keyboard-shortcuts", {
|
||||
|
||||
if (_.isArray(bindings)) {
|
||||
_.each(bindings, registerBinding, this);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
registerBinding(bindings);
|
||||
}
|
||||
},
|
||||
@ -28,38 +27,39 @@ QUnit.module("lib:keyboard-shortcuts", {
|
||||
|
||||
sandbox.stub(DiscourseURL, "routeTo");
|
||||
|
||||
$("#qunit-fixture").html([
|
||||
"<article class='topic-post selected'>",
|
||||
"<a class='post-date'></a>" +
|
||||
"</article>",
|
||||
"<div class='notification-options'>",
|
||||
" <ul>",
|
||||
" <li data-id='0'><a></a></li>",
|
||||
" <li data-id='1'><a></a></li>",
|
||||
" <li data-id='2'><a></a></li>",
|
||||
" <li data-id='3'><a></a></li>",
|
||||
" </ul>",
|
||||
"</div>",
|
||||
"<table class='topic-list'>",
|
||||
" <tr class='topic-list-item selected'><td>",
|
||||
" <a class='title'></a>",
|
||||
" </td></tr>",
|
||||
"</table>",
|
||||
"<div id='topic-footer-buttons'>",
|
||||
" <button class='star'></button>",
|
||||
" <button class='create'></button>",
|
||||
" <button class='share'></button>",
|
||||
" <button id='dismiss-new-top'></button>",
|
||||
" <button id='dismiss-topics-top'></button>",
|
||||
"</div>",
|
||||
"<div class='alert alert-info clickable'></div>",
|
||||
"<button id='create-topic'></button>",
|
||||
"<div id='user-notifications'></div>",
|
||||
"<div id='toggle-hamburger-menu'></div>",
|
||||
"<div id='search-button'></div>",
|
||||
"<div id='current-user'></div>",
|
||||
"<div id='keyboard-help'></div>"
|
||||
].join("\n"));
|
||||
$("#qunit-fixture").html(
|
||||
[
|
||||
"<article class='topic-post selected'>",
|
||||
"<a class='post-date'></a>" + "</article>",
|
||||
"<div class='notification-options'>",
|
||||
" <ul>",
|
||||
" <li data-id='0'><a></a></li>",
|
||||
" <li data-id='1'><a></a></li>",
|
||||
" <li data-id='2'><a></a></li>",
|
||||
" <li data-id='3'><a></a></li>",
|
||||
" </ul>",
|
||||
"</div>",
|
||||
"<table class='topic-list'>",
|
||||
" <tr class='topic-list-item selected'><td>",
|
||||
" <a class='title'></a>",
|
||||
" </td></tr>",
|
||||
"</table>",
|
||||
"<div id='topic-footer-buttons'>",
|
||||
" <button class='star'></button>",
|
||||
" <button class='create'></button>",
|
||||
" <button class='share'></button>",
|
||||
" <button id='dismiss-new-top'></button>",
|
||||
" <button id='dismiss-topics-top'></button>",
|
||||
"</div>",
|
||||
"<div class='alert alert-info clickable'></div>",
|
||||
"<button id='create-topic'></button>",
|
||||
"<div id='user-notifications'></div>",
|
||||
"<div id='toggle-hamburger-menu'></div>",
|
||||
"<div id='search-button'></div>",
|
||||
"<div id='current-user'></div>",
|
||||
"<div id='keyboard-help'></div>"
|
||||
].join("\n")
|
||||
);
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
@ -93,9 +93,13 @@ _.each(clickBindings, function(selector, binding) {
|
||||
assert.ok(true, selector + " was clicked");
|
||||
});
|
||||
|
||||
_.each(bindings, function(b) {
|
||||
testMouseTrap.trigger(b);
|
||||
}, this);
|
||||
_.each(
|
||||
bindings,
|
||||
function(b) {
|
||||
testMouseTrap.trigger(b);
|
||||
},
|
||||
this
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -115,14 +119,14 @@ _.each(functionBindings, function(func, binding) {
|
||||
});
|
||||
|
||||
QUnit.test("selectDown calls _moveSelection with 1", assert => {
|
||||
var spy = sandbox.spy(KeyboardShortcuts, '_moveSelection');
|
||||
var spy = sandbox.spy(KeyboardShortcuts, "_moveSelection");
|
||||
|
||||
KeyboardShortcuts.selectDown();
|
||||
assert.ok(spy.calledWith(1), "_moveSelection is called with 1");
|
||||
});
|
||||
|
||||
QUnit.test("selectUp calls _moveSelection with -1", assert => {
|
||||
var spy = sandbox.spy(KeyboardShortcuts, '_moveSelection');
|
||||
var spy = sandbox.spy(KeyboardShortcuts, "_moveSelection");
|
||||
|
||||
KeyboardShortcuts.selectUp();
|
||||
assert.ok(spy.calledWith(-1), "_moveSelection is called with -1");
|
||||
@ -130,7 +134,7 @@ QUnit.test("selectUp calls _moveSelection with -1", assert => {
|
||||
|
||||
QUnit.test("goBack calls history.back", assert => {
|
||||
var called = false;
|
||||
sandbox.stub(history, 'back', function() {
|
||||
sandbox.stub(history, "back", function() {
|
||||
called = true;
|
||||
});
|
||||
|
||||
@ -139,14 +143,14 @@ QUnit.test("goBack calls history.back", assert => {
|
||||
});
|
||||
|
||||
QUnit.test("nextSection calls _changeSection with 1", assert => {
|
||||
var spy = sandbox.spy(KeyboardShortcuts, '_changeSection');
|
||||
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
|
||||
|
||||
KeyboardShortcuts.nextSection();
|
||||
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
|
||||
});
|
||||
|
||||
QUnit.test("prevSection calls _changeSection with -1", assert => {
|
||||
var spy = sandbox.spy(KeyboardShortcuts, '_changeSection');
|
||||
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
|
||||
|
||||
KeyboardShortcuts.prevSection();
|
||||
assert.ok(spy.calledWith(-1), "_changeSection is called with -1");
|
||||
|
Reference in New Issue
Block a user