-
Notifications
You must be signed in to change notification settings - Fork 3
/
removePetals.test.js
56 lines (49 loc) · 2.12 KB
/
removePetals.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { jest } from '@jest/globals';
import DaisyGame from './removePetals.js';
describe('sample',()=>{
test('1+1 = 2',()=>{
expect(1+1).toBe(2);
})
})
describe('testing Daisy',()=>{
let daisy;
beforeEach(()=>{
daisy = new DaisyGame();
})
describe('testing object',()=>{
test('daisy is an instance of Daisy',()=>{
// const daisy = new DaisyGame();
expect(daisy).toBeInstanceOf(DaisyGame);
})
})
describe('testing play method',()=>{
test('play() should call deshojarMargarita()',async ()=>{
// const daisy = new DaisyGame();
const spyDeshojarMargarita = jest.spyOn(daisy,'deshojarMargarita')
.mockImplementation(()=>Promise.resolve('me quiere'));
await daisy.play();
expect(spyDeshojarMargarita).toHaveBeenCalledTimes(1);
})
test('play() should call printBlue()',async ()=>{
const spyDeshojarMargarita = jest.spyOn(daisy,'deshojarMargarita')
.mockImplementation(()=>Promise.resolve('me quiere'));
const spyPrintBlue = jest.spyOn(daisy, 'printBlue');
await daisy.play();
expect(spyPrintBlue).toHaveBeenCalledTimes(1);
})
test('play() should not call printBlue()',async ()=>{
const spyDeshojarMargarita = jest.spyOn(daisy,'deshojarMargarita')
.mockImplementation(()=>Promise.reject('no me quiere'));
const spyPrintBlue = jest.spyOn(daisy, 'printBlue');
await daisy.play();
expect(spyPrintBlue).not.toHaveBeenCalled();
})
test('play() should call printRed()',async ()=>{
const spyDeshojarMargarita = jest.spyOn(daisy,'deshojarMargarita')
.mockImplementation(()=>Promise.reject('no me quiere'));
const spyPrintRed = jest.spyOn(daisy, 'printRed');
await daisy.play();
expect(spyPrintRed).toHaveBeenCalledTimes(1);
})
})
})