@almin/store-test-helper
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

@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.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Readme

Keywords

Package Sidebar

Install

npm i @almin/store-test-helper

Weekly Downloads

6

Version

1.1.4

License

MIT

Unpacked Size

15.9 kB

Total Files

12

Last publish

Collaborators

  • azu