react-ghost-test

test utils for react-ghost library

Usage no npm install needed!

<script type="module">
  import reactGhostTest from 'https://cdn.skypack.dev/react-ghost-test';
</script>

README

react-ghost-test

Test utilities for react-ghost

Usage

import { crate, getTestUtils } from 'react-ghost-test'

const { waitForState, checkDispatch } = getTestUtils;

describe('init', () => {
  test('create app actor', async () => {
    await waitForState(
      () => create(ghost(
        StoreProvider,
        { value: store },
        ghost(AppActor),
      )),
      [
        (state) => expect(state).toHaveProperty('main'),
      ],
    );
  });

  test('boot', async () => {
    await checkDispatch(
      mainActions.boot('main'),
      [
        (state) => state.toHaveProperty('main.booting', true),
        (state) => state.toMatchObject({
          main: {
            booted: true,
            booting: false,
          },
          history: {
            location: { pathname: '/' },
          },
        }),
        (state) => state.toMatchObject({
          homePage: {
            title: 'Home Page',
          },
        }),
      ],
    );
  });
});