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

[bug] [discussion] [feature request] Asserting all array elements have the type #16

Open
hellboy81 opened this issue Jul 16, 2015 · 2 comments

Comments

@hellboy81
Copy link

Assume

var list = ['1', '2']

This code does not works:

should.exist(list)

list.should.be.an('array') // Passed
     .with.length(2) // Passed
     .and.all.be.an('string') // Failed: expected '1' to be a string
@victorherraiz
Copy link

+1

var a = [{id:1}, {id:2}]; 
expect(a[0]).property("id").is.a("number"); //works
expect(a).all.property("id").is.a("number"); //fails

@hellboy81
Copy link
Author

With unexpected.js it should work as follows:

expect(list, 'to be an array whose items satisfy', expect.it('to be a string')) 

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

2 participants