chaijs / chai-things

Chai support for assertions on array elements
http://chaijs.com/plugins/chai-things
Other
104 stars 14 forks source link

Run a chai assertion for all elements in the array #2

Closed sebpiq closed 11 years ago

sebpiq commented 11 years ago

for example


expect([1, 2, 3]).elements.to.be('number')
RubenVerborgh commented 11 years ago

Good idea. I've been thinking of this too, but never found an appropriate syntax that fits with the existing:

[4, 11, 15].should.include.one.below(10)
[4, 11, 15].should.contain.some.above(10)
[4, 11, 15].should.not.contain.any.above(20)
[{ a: 'cat' }, { a: 'dog' }].should.contain.a.thing.with.property('a', 'cat')
[{ a: 'cat' }, { a: 'dog' }].should.contain.an.item.with.property('a', 'dog')

Any suggestions? I think elements is rather vague.

Some of mine would be:

[4, 11, 15].should.all.be.below(20)
[{ a: 'cat' }, { a: 'dog' }].should.all.have.property('a')
sebpiq commented 11 years ago

Well ... to me all fits perfectly your current syntax!

RubenVerborgh commented 11 years ago

Here you go :hatching_chick: Tell me how you like it! Also, I'm always interested to see projects you're using Chai-Things in.