(git: SimpleGit)
| 93 | } |
| 94 | |
| 95 | export async function simulateGitFetch(git: SimpleGit) { |
| 96 | let fetchHead: string = await git.branchLocal().then(resp => resp.current); |
| 97 | |
| 98 | vi.spyOn(git, 'fetch').mockImplementation((...args) => { |
| 99 | fetchHead = (args as unknown as [string, string, string[]])[1]; |
| 100 | return Promise.resolve({}) as Response<FetchResult>; |
| 101 | }); |
| 102 | |
| 103 | const originalDiffSummary = git.diffSummary.bind(git); |
| 104 | const originalDiff = git.diff.bind(git); |
| 105 | |
| 106 | vi.spyOn(git, 'diffSummary').mockImplementation(args => |
| 107 | originalDiffSummary( |
| 108 | (args as unknown as string[]).map(arg => |
| 109 | arg === 'FETCH_HEAD' ? fetchHead : arg, |
| 110 | ), |
| 111 | ), |
| 112 | ); |
| 113 | vi.spyOn(git, 'diff').mockImplementation(args => |
| 114 | originalDiff( |
| 115 | (args as string[]).map(arg => (arg === 'FETCH_HEAD' ? fetchHead : arg)), |
| 116 | ), |
| 117 | ); |
| 118 | } |
no outgoing calls
no test coverage detected