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

expect(...).to.include should support ES2015 Sets and Maps #970

Closed
mdziekon opened this issue May 22, 2017 · 3 comments
Closed

expect(...).to.include should support ES2015 Sets and Maps #970

mdziekon opened this issue May 22, 2017 · 3 comments

Comments

@mdziekon
Copy link

It seems like Chai supports key assertions on ES2015 sets & maps (introduced in this PR: #633), but it does not support simple "inclusion" assertions.

Consider the following testcase:

it("should detect item existence in Set", function () {
    let container = new Set();

    container.add(123);

    expect(container).to.include(123);
});

This test should obviously pass, as the container has 123 value added to it. Instead, it fails with the following error:

AssertionError: object tested must be an array, an object, or a string, but set given

Same thing happens if we change Set to Map (container.set("somekey", 123)).


As far as I know, this problem occurs both in 3.5.0 version, as well as the latest 4.0.0-canary.2 pre-release version.

@meeber
Copy link
Contributor

meeber commented May 27, 2017

@mdziekon Agreed. This one seems fairly straightforward.
@lucasfcosta @vieiralucas @shvaikalesh @keithamus Any objection to requesting a PR?

@lucasfcosta
Copy link
Member

lucasfcosta commented May 28, 2017

I totally agree. Seems simple, straightforward and also very useful.

@vieiralucas
Copy link
Member

LGTM

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

No branches or pull requests

4 participants