From d01db82c0dca352de2d7644c383d388fc3ec0366 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 2 May 2019 14:08:51 +0900 Subject: Types src/content --- test/shared/operations.test.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/shared/operations.test.ts (limited to 'test/shared') diff --git a/test/shared/operations.test.ts b/test/shared/operations.test.ts new file mode 100644 index 0000000..42a3eed --- /dev/null +++ b/test/shared/operations.test.ts @@ -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); + }); + }); +}) -- cgit v1.2.3