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

add contains assert #320

Closed
wants to merge 2 commits into from
Closed

add contains assert #320

wants to merge 2 commits into from

Conversation

brunoqueiros
Copy link

A new assert to check if a string contains certain string.

t.contains(value, expected, [message]);

@sindresorhus
Copy link
Member

Hmm, not sure about this. Now that we have power-assert support it doesn't really make sense to add a bunch more assertion methods as you can just use t.true(). In this case it would be t.true(foo.includes('bar'));, although [].includes is currently not working, but will be fixed.

@brunoqueiros
Copy link
Author

I think that is easier to have more assertions because the test file will be cleaner and more easy to maintaining. I think there should have both, that way the user can choose what use.

@sindresorhus
Copy link
Member

t.contains(foo, 'bar');
// vs
t.ok(foo.includes('bar'));

// @twada @uiureo

@shinnn
Copy link

shinnn commented Dec 10, 2015

Contrary to the PR author's opinion, t.contains won't simplify the test file, I think.

There are a lot of JavaScript objects that have indexOf method (array, string, Node's buffer, ...), but this t.contains function doesn't check its argument type. So whenever we use t.contains we should also check the object type.

@brunoqueiros
Copy link
Author

It's not even necessary, your arguments are right. I'll close the PR.

@twada
Copy link
Contributor

twada commented Dec 10, 2015

I agree with @sindresorhus and @shinnn.

I've developed power-assert to prevent tests from bloating assertion methods. Less is more.

I know it's a bit opinionated. But AVA is opinionated too ;)

@brunoqueiros brunoqueiros deleted the assert-contains branch December 10, 2015 13:04
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 this pull request may close these issues.

4 participants