reactant-module
Version:
A module model for Reactant
53 lines (50 loc) • 1.09 kB
text/typescript
import {
injectable,
createState,
createContainer,
createStore,
action,
state,
ReactantAction,
} from '../..';
test('`createState` with type', () => {
()
class Counter {
count = createState<number, ReactantAction>(($state = 0) => $state);
increase() {
this.count += 1;
}
}
const ServiceIdentifiers = new Map();
const modules = [Counter];
const container = createContainer({
ServiceIdentifiers,
modules,
options: {
defaultScope: 'Singleton',
},
});
const counter = container.get(Counter);
const store = createStore({
modules,
container,
ServiceIdentifiers,
loadedModules: new Set(),
load: (...args: any[]) => {},
dynamicModules: new Map(),
pluginHooks: {
middleware: [],
beforeCombineRootReducers: [],
afterCombineRootReducers: [],
enhancer: [],
preloadedStateHandler: [],
afterCreateStore: [],
provider: [],
},
});
expect(counter.count).toBe(0);
counter.increase();
expect(counter.count).toBe(1);
});