Skip to content

Add validity middleware mock and tests#631

Merged
nicknisi merged 3 commits intodojo:masterfrom
nicknisi:validity-mock
Jan 6, 2020
Merged

Add validity middleware mock and tests#631
nicknisi merged 3 commits intodojo:masterfrom
nicknisi:validity-mock

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

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

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.

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
@nicknisi nicknisi deleted the validity-mock branch January 6, 2020 19:09
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 validity middleware mock

2 participants