Skip to content

Add focus middleware mock and tests#635

Merged
nicknisi merged 1 commit intodojo:masterfrom
nicknisi:focus-mock
Jan 6, 2020
Merged

Add focus middleware mock and tests#635
nicknisi merged 1 commit intodojo:masterfrom
nicknisi:focus-mock

Conversation

@nicknisi
Copy link
Copy Markdown
Member

@nicknisi nicknisi commented Jan 6, 2020

Type: feature

The following has been addressed in the PR:

Description:

This adds a focus middleware mock that is capable of mocking the return value of the middleware's isFocused method.

const focusMock = createFocusMock();
const factory = create({ focus });
const App = factory(({ middleware: { focus } }) => {
	return <div key="root">{focus.isFocused('root') ? 'focus' : 'no focus'}</div>;
});
const h = harness(() => <App />, { middleware: [[focus, focusMock]] });

focusMock('root', false);
h.expect(() => <div key="root">no focus</div>);

focusMock('root', true);
h.expect(() => <div key="root">focus</div>);

Resolves #627

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Jan 6, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8ea5fc1:

Sandbox Source
jolly-sky-3u33q Configuration

@nicknisi nicknisi merged commit a16782d into dojo:master Jan 6, 2020
@nicknisi nicknisi deleted the focus-mock branch January 6, 2020 18:35
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

Successfully merging this pull request may close these issues.

Add a focus middleware mock

2 participants