Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Middleware Mock #834

Open
samends opened this issue Sep 3, 2020 · 0 comments
Open

Resource Middleware Mock #834

samends opened this issue Sep 3, 2020 · 0 comments

Comments

@samends
Copy link
Contributor

samends commented Sep 3, 2020

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);
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant