class Human {
constructor (firstName, lastName) {
this.firstName = firstName || ""
this.lastName = lastName || ""
}
filterMyFamily(humans) {
return humans.filter(human => (human.lastName == this.lastName))
}
}
var expect = require("chai").expect
let james = new Human("James","Black")
let billy = new Human("Billy","White")
let sam = new Human("Sam","Blue")
let nick = new Human("Nick","Blue")
let justSue = new Human("Sue")
describe("constructor", function() {
it("should initialize objects", function() {
expect(james).to.be.an.instanceof(Human)
//Test.expect(james instanceof Human, "james is a Human")
})
it("fill default property values", function() {
expect(justSue.lastName).to.be.a('string')
})
})
describe("filterMyFamily", function(){
it("function works properly", function(){
let meeting = [james, billy, sam, nick]
let filtered = nick.filterMyFamily(meeting)
expect(filtered).to.be.a('array')
expect(filtered).to.include(sam)
expect(filtered).to.have.length.within(2,2)
});
});