dojo / dojo/framework

Resource Middleware Mock

Open
#834 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
623
Forks
78
PR merge metrics
No merged PRs in 30d

Description

**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 by`meta()` 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(() => Loading);
const mockResource = createResourceMock({
isLoading: true
meta: { total: 4 }
});
const r = renderer(() => , { middleware: [[createICacheMiddleware(), mockResource]] });
r.expect(baseAssertion);
});
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.