chai-things
chai-things copied to clipboard
[bug] [discussion] [feature request] Asserting all array elements have the type
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
+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
With unexpected.js it should work as follows:
expect(list, 'to be an array whose items satisfy', expect.it('to be a string'))