diff --git a/src/actions.test.js b/src/actions.test.js deleted file mode 100644 index 8c35f98..0000000 --- a/src/actions.test.js +++ /dev/null @@ -1,38 +0,0 @@ -import updux from '.'; -import u from 'updeep'; - -test( 'actions defined in effects and mutations, multi-level', () => { - - const { actions } = updux({ - effects: { - foo: api => next => action => { }, - }, - mutations: { bar: () => () => null }, - subduxes: { - mysub: { - effects: { baz: api => next => action => { }, }, - mutations: { quux: () => () => null }, - actions: { - foo: (limit) => ({limit}), - }, - }, - myothersub: { - effects: { - foo: () => () => () => {}, - }, - } - }, - }); - - const types = Object.keys(actions); - types.sort(); - - expect( types).toEqual([ 'bar', 'baz', 'foo', 'quux', ]); - - expect( actions.bar() ).toEqual({ type: 'bar' }); - expect( actions.bar('xxx') ).toEqual({ type: 'bar', payload: 'xxx' }); - expect( actions.bar(undefined,'yyy') ).toEqual({ type: 'bar',meta: 'yyy' }); - - expect(actions.foo(12)).toEqual({type: 'foo', payload: { limit: 12 }}); - -}); diff --git a/src/actions.test.ts b/src/actions.test.ts new file mode 100644 index 0000000..4ec6492 --- /dev/null +++ b/src/actions.test.ts @@ -0,0 +1,38 @@ +import updux from '.'; +import u from 'updeep'; + +const noopEffect = () => () => () => {}; + +test('actions defined in effects and mutations, multi-level', () => { + const {actions} = updux({ + effects: { + foo: noopEffect, + }, + mutations: {bar: () => () => null}, + subduxes: { + mysub: { + effects: {baz: noopEffect }, + mutations: {quux: () => () => null}, + actions: { + foo: (limit:number) => ({limit}), + }, + }, + myothersub: { + effects: { + foo: noopEffect, + }, + }, + }, + }); + + const types = Object.keys(actions); + types.sort(); + + expect(types).toEqual(['bar', 'baz', 'foo', 'quux']); + + expect(actions.bar()).toEqual({type: 'bar'}); + expect(actions.bar('xxx')).toEqual({type: 'bar', payload: 'xxx'}); + expect(actions.bar(undefined, 'yyy')).toEqual({type: 'bar', meta: 'yyy'}); + + expect(actions.foo(12)).toEqual({type: 'foo', payload: {limit: 12}}); +});