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

Handle arrays with null elements #13

Open
carpiediem opened this issue Aug 29, 2018 · 1 comment
Open

Handle arrays with null elements #13

carpiediem opened this issue Aug 29, 2018 · 1 comment

Comments

@carpiediem
Copy link

It would be great if the library included a configuration parameter that would let users define how null values should be handled. There ought to be three options:

  1. Any null values should trigger a failed assertion (current behavior)
  2. Expect all null elements to be placed before -∞ (depending on sort order)
  3. Expect all null elements to be placed after +∞ (depending on sort order)

Maybe something like this?

expect(["b","apples",null]).to.be.sorted({descending: true, null:"low"});  // TRUE
expect(["b","apples",null]).to.be.sorted({descending: true, null:"high"});  // FALSE
expect(["b","apples",null]).to.be.sorted({descending: true, null:"none"});  // FALSE
@carpiediem
Copy link
Author

After testing some more, it looks like #2 is the current behavior (which is the probably the best default). Still, it would be nice to have the configuration option.

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

No branches or pull requests

1 participant