commit
f891ccf999
6 changed files with 1348 additions and 19 deletions
@ -0,0 +1,34 @@ |
||||
module.exports = function (config) { |
||||
var webpackConfig = require('./webpack.config.js'); |
||||
|
||||
config.set({ |
||||
basePath: '', |
||||
frameworks: ['mocha'], |
||||
files: ['test/**/*\.test\.js'], |
||||
|
||||
preprocessors: { |
||||
'test/**/*\.test\.js': [ 'webpack' ] |
||||
}, |
||||
|
||||
reporters: ['progress'], |
||||
|
||||
port: 9876, |
||||
colors: true, |
||||
logLevel: config.LOG_INFO, |
||||
browsers: ['Firefox'], |
||||
|
||||
singleRun: true, |
||||
|
||||
webpack: { |
||||
devtool: 'inline-source-map', |
||||
resolve: webpackConfig.resolve, |
||||
module: webpackConfig.module |
||||
}, |
||||
|
||||
webpackMiddleware: { |
||||
noInfo: true |
||||
}, |
||||
|
||||
reporters: ['mocha'] |
||||
}) |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,47 @@ |
||||
import { expect } from "chai"; |
||||
import KeyQueue from '../../src/background/key-queue'; |
||||
import * as actions from '../../src/shared/actions'; |
||||
|
||||
describe("keyQueue class", () => { |
||||
const KEYMAP = [ |
||||
{ keys: [{ code: KeyboardEvent.DOM_VK_G }, { code: KeyboardEvent.DOM_VK_G }], |
||||
action: [ actions.SCROLL_TOP ]}, |
||||
{ keys: [{ code: KeyboardEvent.DOM_VK_J }], |
||||
action: [ actions.SCROLL_DOWN ]}, |
||||
] |
||||
|
||||
describe("#push", () => { |
||||
it("returns matched action", () => { |
||||
let queue = new KeyQueue(KEYMAP); |
||||
queue.push({ code: KeyboardEvent.DOM_VK_G }); |
||||
let action = queue.push({ code: KeyboardEvent.DOM_VK_G }); |
||||
|
||||
expect(action).to.deep.equal([ actions.SCROLL_TOP ]); |
||||
}); |
||||
|
||||
it("returns null on no actions matched", () => { |
||||
let queue = new KeyQueue(KEYMAP); |
||||
queue.push({ code: KeyboardEvent.DOM_VK_G }); |
||||
let action = queue.push({ code: KeyboardEvent.DOM_VK_X }); |
||||
|
||||
expect(action).to.be.null; |
||||
}); |
||||
}); |
||||
|
||||
describe("#queuedKeys", () => { |
||||
it("queues keys on matched actions exist", () => { |
||||
let queue = new KeyQueue(KEYMAP); |
||||
queue.push({ code: KeyboardEvent.DOM_VK_G }); |
||||
|
||||
expect(queue.queuedKeys()).to.have.lengthOf(1); |
||||
}); |
||||
|
||||
it("flushs keys on no actions matched", () => { |
||||
let queue = new KeyQueue(KEYMAP); |
||||
queue.push({ code: KeyboardEvent.DOM_VK_G }); |
||||
queue.push({ code: KeyboardEvent.DOM_VK_Z }); |
||||
|
||||
expect(queue.queuedKeys()).to.be.empty; |
||||
}); |
||||
}); |
||||
}); |
Reference in new issue