-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.ts
97 lines (91 loc) · 2.73 KB
/
jest.setup.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import inquirer from 'inquirer';
import simpleGit from 'simple-git/promise';
jest.mock('inquirer', () => ({
prompt: jest.fn().mockReturnValue(Promise.resolve({
whatToDo: 'prune all gone branches'
}))
}));
jest.mock('simple-git/promise', () => {
const DEFAULT_RETURN = {
all: [
'beta',
'feature/improve-things',
'fix-release-files',
'main',
'release/fix-release',
'release/new-main-release'
],
branches: {
beta: {
current: false,
name: 'beta',
commit: '3eaa4c1',
label: '[origin/beta: behind 2] fix(release): add lib files'
},
'feature/improve-things': {
current: true,
name: 'feature/improve-things',
commit: '94337fd',
label: 'chore(release): 1.0.0-beta.2 [skip ci]'
},
'fix-release-files': {
current: false,
name: 'fix-release-files',
commit: '3eaa4c1',
label: 'fix(release): add lib files'
},
main: {
current: false,
name: 'main',
commit: 'cd2ec48',
label: '[origin/main: behind 16] ci(github): add pipelines'
},
'release/fix-release': {
current: false,
name: 'release/fix-release',
commit: '8f64df7',
label: '[origin/release/fix-release: gone] message'
},
'release/new-main-release': {
current: false,
name: 'release/new-main-release',
commit: 'a71bc34',
label: '[origin/release/new-main-release: gone] message'
}
},
current: 'feature/improve-things',
detached: false
};
const DELETED_BRANCHES = {
all: [{
branch: 'release/fix-release',
success: true
}]
};
const simplePromiseBranchMock = jest.fn()
.mockImplementation(() => {
return Promise.resolve(simplePromise.branchReturnObj);
});
const simpleDeleteLocalBranchesMock = jest.fn()
.mockImplementation(() => {
return Promise.resolve(simplePromise.deleteReturnObj);
});
const simplePromise = () => ({
branch: simplePromiseBranchMock,
deleteLocalBranches: simpleDeleteLocalBranchesMock,
fetch: () => jest.fn().mockImplementation(() => console.log('fetched!'))
});
simplePromise.branchReturnObj = DEFAULT_RETURN;
simplePromise.deleteReturnObj = DELETED_BRANCHES;
simplePromise.clearMocks = () => {
simplePromise.branchReturnObj = DEFAULT_RETURN;
simplePromise.deleteReturnObj = DELETED_BRANCHES;
simplePromiseBranchMock.mockClear();
simpleDeleteLocalBranchesMock.mockClear();
};
return simplePromise;
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const simpleGitMock = simpleGit;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const inquirerMock = inquirer;