Skip to content

Commit

Permalink
adds test for keycode method
Browse files Browse the repository at this point in the history
  • Loading branch information
Knape committed Jun 21, 2017
1 parent 68c3bb7 commit 8f144e2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/specs/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { center, position } from '../../src/utils/position.utils';
import touches from '../../src/events/touch.utils';
import keyCode from '../../src/events/keyboard.utils';
import { hasKeys } from '../../src/utils/helpers.utils';

let element;
Expand Down Expand Up @@ -92,11 +93,29 @@ describe('th', () => {
describe('should return an array of points', () => {
it('window center if no arguments are passed', () => {
const points = touches(position(), center(), position());
expect(points).to.be.an.array;
expect(points).to.be.an.object;
expect(points).to.have.any.keys('touches');
expect(points.touches).to.have.lengthOf(3);
});
});
});

describe('keyCode', () => {
it('should be a function', () => {
expect(typeof keyCode).to.eql('function');
});

it('should convert name to key string and nest it inside key object', () => {
const keyboardOptions = keyCode('enter');
expect(keyboardOptions.key).to.eql('13')
});

it('should convert key and merge object', () => {
const keyboardOptions = keyCode('65', {});
expect(keyboardOptions.key).to.eql('a')
});
});

describe('hasKeys', () => {
it('should be a function', () => {
expect(typeof hasKeys).to.eql('function');
Expand Down

0 comments on commit 8f144e2

Please sign in to comment.