1.0.0 • Published 5 years ago

@mst-ds/mst-jest v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

mst-jest

API

createMSTSnapshot(node) - created jest snapshot from model
getEnvMock({...}) - mocked for getEnv'
getRootMock({...}) - mocked for getRoot'
onPatchesAggregation(node) - aggregate all model patches, and take a jest snapshot'
onSnapshotAggregation(node) - aggregate all model snapshots, and take a jest snapshot'

Usage

import { types } from "mobx-state-tree"
import { createMSTSnapshot, onPatchesAggregation, onSnapshotAggregation } from "@mst-ds/mst-jest"

describe('Tests', () => {
    it('snapshot test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        createMSTSnapshot(list) // create jest snapshot
    });
it('snapshots test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        const disposer = onPatchesAggregation(list)

        rootStore.action1();
        rootStore.action2();
        rootStore.action3();

        disposer() // create jest snapshot
    });
    it('patches test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        const disposer = onSnapshotAggregation(list)

        rootStore.action1();
        rootStore.action2();
        rootStore.action3();

        disposer() // create jest snapshot
    });
});
1.0.0

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.1

5 years ago