Last active
August 8, 2021 06:04
-
-
Save andreipfeiffer/bc38ee6387e8cfe6f1a87e8a01d02a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect.extend({ | |
toContainObject(received, argument) { | |
const pass = this.equals(received, | |
expect.arrayContaining([ | |
expect.objectContaining(argument) | |
]) | |
) | |
if (pass) { | |
return { | |
message: () => (`expected ${this.utils.printReceived(received)} not to contain object ${this.utils.printExpected(argument)}`), | |
pass: true | |
} | |
} else { | |
return { | |
message: () => (`expected ${this.utils.printReceived(received)} to contain object ${this.utils.printExpected(argument)}`), | |
pass: false | |
} | |
} | |
} | |
}) | |
const state = [ | |
{ type: 'START', data: 'foo' }, | |
{ type: 'START', data: 'baz' }, | |
{ type: 'END', data: 'foo' }, | |
] | |
expect(state).toContainObject({ type: 'START' }) | |
expect(state).toContainObject({ type: 'END' }) | |
expect(state).toContainObject({ data: 'foo' }) | |
expect(state).not.toContainObject({ type: 'NONE' }) | |
expect(state).not.toContainObject({ data: 'bar' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment