aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
Diffstat (limited to 'test/shared')
-rw-r--r--test/shared/operations.test.ts41
1 files changed, 41 insertions, 0 deletions
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);
+ });
+ });
+})