forked from eritikass/kta-19e_tund1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheep.test.js
34 lines (33 loc) · 1.14 KB
/
sheep.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
const Sheep = require('./sheep');
describe('Sheep class', () => {
describe('.getName', () => {
test('create Sheep with name Dolly, check that name is Dolly', () => {
const s = new Sheep('Dolly');
expect(s.getName()).toBe('Dolly');
});
test('create Sheep with name Sally, check that name is Sally', () => {
const s = new Sheep('Sally');
expect(s.getName()).toBe('Sally');
});
});
describe('.setName', () => {
test('create Sheep with name Sally, change name to Dolly, check name is now Dolly', () => {
const s = new Sheep('Dolly');
expect(s.getName()).toBe('Dolly');
s.setName('Sally');
expect(s.getName()).toBe('Sally');
});
test('new name given (Dolly -> Sally)', () => {
const s = new Sheep('Dolly');
expect(s.getName()).toBe('Dolly');
expect(s.setName('Sally')).toBe(true);
expect(s.getName()).toBe('Sally');
});
test('no new name given (Dolly -> Dolly)', () => {
const s = new Sheep('Dolly');
expect(s.getName()).toBe('Dolly');
expect(s.setName('Dolly')).toBe(false);
expect(s.getName()).toBe('Dolly');
});
});
});