forked from and-digital/and-workshop-corejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_classes.test.js
38 lines (26 loc) · 857 Bytes
/
05_classes.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
describe('About classes', () => {
/*
Task 1) Refactor the following traditional Javascript "class" into new class syntax
*/
function Animal() {}
Animal.prototype.speak = function() {
return 'meow';
};
Animal.eat = function() {
return 'nom nom nom';
};
it('should make the cat meow and animal eat', () => {
const Cat = new Animal();
expect(Cat.speak()).toBe('meow');
expect(Animal.eat()).toBe('nom nom nom');
});
/*
Task 2) Create a class Kitten, that extends the Animal. Overwriting the previous speak method.
The test should fail when you add the extended class, you will need to override the method for the test to pass
Tip: Use extends keyword
*/
it('should hear the kitten meow', () => {
const Kitty = new Kitten();
expect(Kitty.speak()).toBe('kitten meow');
});
});