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

Add validity middleware mock and tests #631

Merged
merged 3 commits into from Jan 6, 2020
Merged

Conversation

nicknisi
Copy link
Member

@nicknisi nicknisi commented Jan 3, 2020

Type: feature

The following has been addressed in the PR:

Description:

This adds a validity middleware mock and tests for it.

const App = factory(({ middleware: { validity } }) => {
	const { valid, message } = validity.get('test', 'test value');
	return !valid ? <div>{message}</div> : <div>valid</div>;
});

validityMock('test', { valid: false, message: 'test message' });
let h = harness(() => <App />, { middleware: [[validity, validityMock]] });
h.expect(() => <div>test message</div>);

Resolves #630

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 3, 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 8592d3c:

Sandbox Source
focused-allen-hq6r7 Configuration

invalidate = invalidator;
return {
get(key: string | number, value: string) {
value;
Copy link
Contributor

@matt-gadd matt-gadd Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to be here?

Copy link
Member Author

@nicknisi nicknisi Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, no I meant to remove that. I originally added it because value is unused and I was quieting TypeScript. Renaming the argument to _value to quiet TypeScript instead.

nicknisi added 3 commits Jan 6, 2020
Instead of mocking the whole middleware, node node middleware is mocked
and the mock function returns an object representing the node with
the properties to look at for validation.
@nicknisi nicknisi merged commit 721baa7 into dojo:master Jan 6, 2020
5 checks passed
@nicknisi nicknisi deleted the validity-mock branch Jan 6, 2020
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.

2 participants