From 12da660b7a3a6fa7c670765bc1efe7e6c8251ea2 Mon Sep 17 00:00:00 2001 From: sisisin Date: Sat, 8 Aug 2020 16:45:13 +0900 Subject: [PATCH] test: cover test case of actions with different signatures --- packages/typeless-router/i.js | 2 ++ packages/typeless/__tests__/type/Epic.test.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 packages/typeless-router/i.js diff --git a/packages/typeless-router/i.js b/packages/typeless-router/i.js new file mode 100644 index 0000000..5debeb8 --- /dev/null +++ b/packages/typeless-router/i.js @@ -0,0 +1,2 @@ +console.log(require('typeless')) +console.log(require.main) \ No newline at end of file diff --git a/packages/typeless/__tests__/type/Epic.test.ts b/packages/typeless/__tests__/type/Epic.test.ts index 8e4ca61..edc33a3 100644 --- a/packages/typeless/__tests__/type/Epic.test.ts +++ b/packages/typeless/__tests__/type/Epic.test.ts @@ -6,11 +6,11 @@ function createAction(acts: T) { return createModule(Symbol('test')).withActions(acts)[1]; } TT.describe('onMany', () => { - const m1 = createAction({ foo: () => ({ payload: 1 }) }); - const m2 = createAction({ foo: () => ({ payload: true }) }); + const m1 = createAction({ foo: (num: number) => ({ payload: { num } }) }); + const m2 = createAction({ foo: (boo: boolean) => ({ payload: { boo } }) }); const m3 = createAction({ foo: () => ({ payload: 'bar' }) }); const m4 = createAction({ foo: () => ({ payload: Symbol('baz') }) }); - const m5 = createAction({ foo: () => ({ payload: { obj: 'foo' } }) }); + const m5 = createAction({ foo: (str: string) => ({ payload: { str } }) }); const m6 = createAction({ foo: () => ({ payload: ['array'] }) }); TT.describe('should error called with', () => { @@ -27,11 +27,11 @@ TT.describe('onMany', () => { TT.it('called with many arguments', () => { new Epic().onMany([m1.foo, m2.foo, m3.foo, m4.foo, m5.foo, m6.foo], p => { type Expected = - | number - | boolean + | { num: number } + | { boo: boolean } | string | symbol - | { obj: string } + | { str: string } | string[]; TT.assert>();