Skip to content

Resource Middleware Mock #834

Open
Open

Description

@samends

Enhancement Resource middleware mock

As we start using the resource middleware more it could be useful to have a resource mock to use when testing. I'd imagine this could be similar to the createICacheMock that already exists. We could use such a mock when testing out some harder to mock out scenarios such as asynchronous resource calls or when testing for specific values such as when a value is returned bymeta() but isLoading is true.

The resource mock could then be used like this:

describe('MyWidget', () => {
    it('test', async () => {
        const WrappedRoot = wrap('div');
        const baseAssertion = assertion(() => <WrappedRoot>Loading</WrappedRoot>);
        const mockResource = createResourceMock({
                isLoading: true
                meta: { total: 4 }
        });
        const r = renderer(() => <Home />, { middleware: [[createICacheMiddleware(), mockResource]] });
        r.expect(baseAssertion);
    });
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions