-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual.test.ts
58 lines (39 loc) · 1.31 KB
/
manual.test.ts
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
56
57
58
import * as dependency from './manual';
jest.mock('./manual');
const manual = jest.mocked(dependency);
describe('lib.manual.get', () => {
it('should provide the manually mocked value', () => {
expect.assertions(1);
const result = manual.get('a b c');
expect(result).toStrictEqual(['a', 'b', 'c']);
});
it('should override the manually mocked value', () => {
expect.assertions(1);
manual.get.mockReturnValueOnce(['d', 'e', 'f']);
const result = manual.get('a b c');
expect(result).toStrictEqual(['d', 'e', 'f']);
});
it('should provide a value to manual.get', () => {
expect.assertions(1);
manual.get('a b c');
expect(manual.get).toHaveBeenCalledWith('a b c');
});
});
describe('lib.manual.put', () => {
it('should provide the manually mocked value', () => {
expect.assertions(1);
const result = manual.put(['a', 'b', 'c']);
expect(result).toBe('a b c');
});
it('should override the manually mocked value', () => {
expect.assertions(1);
manual.put.mockReturnValueOnce('d e f');
const result = manual.put(['a', 'b', 'c']);
expect(result).toBe('d e f');
});
it('should provide a value to manual.put', () => {
expect.assertions(1);
manual.put(['a', 'b', 'c']);
expect(manual.put).toHaveBeenCalledWith(['a', 'b', 'c']);
});
});