aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-02 14:08:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-05 23:59:59 +0900
commitd01db82c0dca352de2d7644c383d388fc3ec0366 (patch)
treeff09ebc545ce00192dff9e1119b0c9e2cf92fdef /test/shared
parent992b3ac65d7fe86ac7bc3b560960c8bcf86bec69 (diff)
Types src/content
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);
+ });
+ });
+})