Types src/content

This commit is contained in:
Shin'ya Ueoka 2019-05-02 14:08:51 +09:00
parent 992b3ac65d
commit d01db82c0d
62 changed files with 1411 additions and 468 deletions

View file

@ -0,0 +1,41 @@
import * as operations from 'shared/operations';
describe('operations', () => {
describe('#valueOf', () => {
it('returns an Operation', () => {
let op: operations.Operation = operations.valueOf({
type: operations.SCROLL_VERTICALLY,
count: 10,
});
expect(op.type).to.equal(operations.SCROLL_VERTICALLY);
expect(op.count).to.equal(10);
});
it('throws an Error on missing required parameter', () => {
expect(() => operations.valueOf({
type: operations.SCROLL_VERTICALLY,
})).to.throw(TypeError);
});
it('fills default valus of optional parameter', () => {
let op: operations.Operation = operations.valueOf({
type: operations.COMMAND_SHOW_OPEN,
});
expect(op.type).to.equal(operations.COMMAND_SHOW_OPEN)
expect(op.alter).to.be.false;
});
it('throws an Error on mismatch of parameter', () => {
expect(() => operations.valueOf({
type: operations.SCROLL_VERTICALLY,
count: '10',
})).to.throw(TypeError);
expect(() => valueOf({
type: operations.COMMAND_SHOW_OPEN,
alter: 'true',
})).to.throw(TypeError);
});
});
})