const animal = new Animal();
test.ok( animal instanceof Animal, 'should create an instance of Animal' );
const expected = 'generic sound';
const actual = animal.speak();
test.equal( actual, expected, 'should make a generic sound when it speaks' );
let actual, expected;
const reptile = new Reptile();
test.ok( reptile instanceof Reptile, 'should be an instance of Reptile' );
test.ok( reptile instanceof Animal, 'should be an instance of Animal' );
expected = Reptile.SOUND;
actual = reptile.speak();
test.equal( actual, expected, 'should make a reptile sound when it speaks' );
const primate = new Primate();
test.ok( primate instanceof Primate, 'should be an instance of Primate' );
test.ok( primate instanceof Animal, 'should be an instance of Animal' );
expected = Primate.SOUND;
actual = primate.speak();
test.equal( actual, expected, 'should make a primate sound when it speaks' );
Environment
Test-Driven Development
Learn about Constructors and Prototypes
const animal = new Animal();
test.ok( animal instanceof Animal, 'should create an instance of Animal' );
const animal = new Animal();
const expected = 'generic sound';
const actual = animal.speak();
test.equal( actual, expected, 'should make a generic sound when it speaks' );
Inheritance
let actual, expected;
const reptile = new Reptile();
test.ok( reptile instanceof Reptile, 'should be an instance of Reptile' );
test.ok( reptile instanceof Animal, 'should be an instance of Animal' );
expected = Reptile.SOUND;
actual = reptile.speak();
test.equal( actual, expected, 'should make a reptile sound when it speaks' );
const primate = new Primate();
test.ok( primate instanceof Primate, 'should be an instance of Primate' );
test.ok( primate instanceof Animal, 'should be an instance of Animal' );
expected = Primate.SOUND;
actual = primate.speak();
test.equal( actual, expected, 'should make a primate sound when it speaks' );