@almin/store-test-helper
v1.1.4
Published
Create Store helper for testing.
Downloads
35
Readme
@almin/store-test-helper
Create Store helper for testing.
Install
Install with npm:
npm install @almin/store-test-helper
Usage
import { Store } from "almin";
export interface MockStore<T> extends Store<T> {
updateStateWithoutEmit(newState: T): void;
updateState(newState: T): void;
getState(): any;
}
/**
* This helper is for creating Store
* @example
* // state only
* // name is increment number automatically
* createStore({ value: "state" });
* // with name
* createStore("Store Name", { value: "state" });
*
*/
export declare function createStore<T>(storeName: string, initialState: T): MockStore<T>;
export declare function createStore<T>(initialState: T): MockStore<T>;
Example
const initialState = {
value: "value"
};
const store = createStore("TestStore", initialState);
assert.ok(store instanceof Store);
assert.strictEqual(store.name, "TestStore");
assert.deepStrictEqual(store.getState(), initialState);
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test
:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
License
MIT © azu