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

`expect(inList).to.be.oneOf` assertion #534

Merged
merged 3 commits into from Oct 16, 2015

Conversation

Projects
None yet
2 participants
@Droogans
Contributor

Droogans commented Oct 13, 2015

I see now why you wanted to name it oneOf, as opposed to in. The rules for matching against arbitrarily deep objects using _.isEqual() were not very clear. This PR looks to add just enough functionality to support most typical use cases.

This will reject anything in the expect part of the test that is an array or an object. It will only match vai list.indexOf(inList) > -1 allow for strict reference comparisons for all objects that are passed in. For deeply nested objects, only first level members are considered for matches.

Droogans added some commits Oct 13, 2015

feat(matchers): Add value-in-list assertion
Adds a way to test if a value appears in a flat list. Compliments
`include.members` to reverse the order of the input. Now the list
appears in the assertion, as opposed to the `expect`.

Closes #532
@Droogans

This comment has been minimized.

Show comment
Hide comment
@Droogans

Droogans Oct 13, 2015

Contributor

I'll push up a commit with a version bump once this gets slated for a merge into master (or you can just do it for me).

Contributor

Droogans commented Oct 13, 2015

I'll push up a commit with a version bump once this gets slated for a merge into master (or you can just do it for me).

@keithamus

This comment has been minimized.

Show comment
Hide comment
@keithamus

keithamus Oct 13, 2015

Member

@Droogans don't worry about version bumping or anything - that's handled as part of the release process.

Member

keithamus commented Oct 13, 2015

@Droogans don't worry about version bumping or anything - that's handled as part of the release process.

@Droogans

This comment has been minimized.

Show comment
Hide comment
@Droogans

Droogans Oct 14, 2015

Contributor

@keithamus I'm not sure you caught this but I added object support to the PR.

Contributor

Droogans commented Oct 14, 2015

@keithamus I'm not sure you caught this but I added object support to the PR.

@keithamus

This comment has been minimized.

Show comment
Hide comment
@keithamus

keithamus Oct 15, 2015

Member

Sorry @Droogans, I did not. Github (annoyingly) only notifies when someone comments in a PR, not when they push up new changes. For future, I'd recommend any changes to a PR are followed up with a comment to bump to the relevant project, until Github gets their act together 😉

Member

keithamus commented Oct 15, 2015

Sorry @Droogans, I did not. Github (annoyingly) only notifies when someone comments in a PR, not when they push up new changes. For future, I'd recommend any changes to a PR are followed up with a comment to bump to the relevant project, until Github gets their act together 😉

assert.oneOf({ four: 4 }, [1, 2, { four: 4 }]);
}, 'expected { four: 4 } to be one of [ 1, 2, { four: 4 } ]');
});

This comment has been minimized.

@keithamus

keithamus Oct 15, 2015

Member

This is a really nice comprehensive set of tests. Thanks for this.

@keithamus

keithamus Oct 15, 2015

Member

This is a really nice comprehensive set of tests. Thanks for this.

@keithamus

This comment has been minimized.

Show comment
Hide comment
@keithamus

keithamus Oct 16, 2015

Member

Wonderful work @Droogans! Also thank-you for keeping a really nice commit history - I was considering adding some contributing guidelines to enforce Angular style commit messages, and you may have just made a convincing argument with your lovely tidy commits.

Member

keithamus commented Oct 16, 2015

Wonderful work @Droogans! Also thank-you for keeping a really nice commit history - I was considering adding some contributing guidelines to enforce Angular style commit messages, and you may have just made a convincing argument with your lovely tidy commits.

keithamus added a commit that referenced this pull request Oct 16, 2015

Merge pull request #534 from Droogans/be-oneOf-assertion
`expect(inList).to.be.oneOf` assertion

@keithamus keithamus merged commit 6472cb9 into chaijs:master Oct 16, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@renovate renovate bot referenced this pull request Feb 2, 2018

Open

Update dependency chai to v4 #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment