Skip to content

Instantly share code, notes, and snippets.

@crcn
Last active July 7, 2022 14:10
Show Gist options
  • Save crcn/649513464e1fd1cfddda813dde691770 to your computer and use it in GitHub Desktop.
Save crcn/649513464e1fd1cfddda813dde691770 to your computer and use it in GitHub Desktop.
describe(() => {
let ConnectedPage;
// Wrap the page with everything it needs to work
beforeEach(() => {
ConnectedPage = ({ state, ...rest}) => <SomeStoreContext.Provider value={state}>
<Page {...rest} />
</SomeStoreContext.Provider>
});
// Smoke test. useContext should throw an esception if context is not provided
it(`Breaks without connected context`, () => {
expect(() => <Page />).to.throw("Context does not exist error");
});
// Test page with initial state
it(`Connect render the page with connected state`, () => {
<ConnectedPage state={INITIAL_STATE} />
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment