2018-08-17 11:58:47 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2018-08-17 13:38:42 -07:00
|
|
|
import { Keyboard } from 'wherehows-web/constants/keyboard';
|
2018-08-17 11:58:47 -07:00
|
|
|
|
|
|
|
|
module('Unit | Service | hot-keys', function(hooks) {
|
|
|
|
|
setupTest(hooks);
|
|
|
|
|
|
|
|
|
|
test('it exists', function(assert) {
|
2018-08-17 13:38:42 -07:00
|
|
|
const service = this.owner.lookup('service:hot-keys');
|
2018-08-17 11:58:47 -07:00
|
|
|
assert.ok(service);
|
|
|
|
|
});
|
2018-08-17 13:38:42 -07:00
|
|
|
|
|
|
|
|
test('it operates as intended', function(assert) {
|
|
|
|
|
const service = this.owner.lookup('service:hot-keys');
|
|
|
|
|
const theFloorIsLava = () => {
|
|
|
|
|
assert.ok(true, 'The registered function was successfully called');
|
|
|
|
|
};
|
|
|
|
|
const theChairsArePeople = () => {
|
|
|
|
|
assert.ok(false, 'This function should not run after being unregistered');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
assert.expect(2);
|
|
|
|
|
assert.ok(service);
|
|
|
|
|
service.registerKeyMapping(Keyboard.ArrowUp, theFloorIsLava);
|
|
|
|
|
service.applyKeyMapping(Keyboard.ArrowUp);
|
|
|
|
|
|
|
|
|
|
service.registerKeyMapping(Keyboard.Enter, theChairsArePeople);
|
2018-08-20 10:33:08 -07:00
|
|
|
service.unregisterKeyMapping(Keyboard.Enter);
|
2018-08-17 13:38:42 -07:00
|
|
|
service.applyKeyMapping(Keyboard.Enter);
|
|
|
|
|
});
|
2018-08-17 11:58:47 -07:00
|
|
|
});
|