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

Obj is oneOf array of objects #1241

Closed
simon-tannai opened this issue Mar 12, 2019 · 2 comments · Fixed by #1334
Closed

Obj is oneOf array of objects #1241

simon-tannai opened this issue Mar 12, 2019 · 2 comments · Fixed by #1334

Comments

@simon-tannai
Copy link

simon-tannai commented Mar 12, 2019

Hi ! :)

I would to test if an object if one of entries from an array containing objects.
It's something like: expect({}).to.deep.oneOf([{}, {}, {}])

But I got this error: AssertionError: expected { Object (type, sender, ...) } to be one of [ Array(3) ]

With more details, this is the test with the object and the array:

expect({
  "type": "text",
  "sender": "bot",
  "user": "USER_TEST",
  "payload": {
    "value": "Lorem ipsum"
  }
}).to.deep.oneOf([
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Dolor sit amet"
    }
  },
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Lorem ipsum"
    }
  },
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Consectetur adipiscing elit"
    }
  }
])

How can I do this kind of test ?

@bdcarr
Copy link

bdcarr commented Sep 24, 2019

Having the same issue; my example can be simplified straight down to this:

expect([]).to.be.deep.oneOf([[], ''])

image

Looks like oneOf doesn't check for deep?

@pintonos
Copy link

Is there any update on this?

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 a pull request may close this issue.

3 participants