2019-10-22 22:15:08 +00:00
|
|
|
"use strict";
|
2019-10-24 15:52:36 +00:00
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const _1 = __importDefault(require("."));
|
|
|
|
const noopEffect = () => () => () => { };
|
2019-10-22 22:15:08 +00:00
|
|
|
test('actions defined in effects and mutations, multi-level', () => {
|
2019-11-05 01:34:14 +00:00
|
|
|
const { actions } = new _1.default({
|
2019-10-22 22:15:08 +00:00
|
|
|
effects: {
|
2019-10-24 15:52:36 +00:00
|
|
|
foo: noopEffect,
|
2019-10-22 22:15:08 +00:00
|
|
|
},
|
2019-10-24 15:52:36 +00:00
|
|
|
mutations: { bar: () => () => null },
|
|
|
|
subduxes: {
|
|
|
|
mysub: {
|
|
|
|
effects: { baz: noopEffect },
|
|
|
|
mutations: { quux: () => () => null },
|
|
|
|
actions: {
|
|
|
|
foo: (limit) => ({ limit }),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
myothersub: {
|
|
|
|
effects: {
|
|
|
|
foo: noopEffect,
|
|
|
|
},
|
|
|
|
},
|
2019-10-22 22:15:08 +00:00
|
|
|
},
|
2019-10-24 15:52:36 +00:00
|
|
|
});
|
|
|
|
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 } });
|
|
|
|
});
|
|
|
|
//# sourceMappingURL=actions.test.js.map
|