-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathmock.d.ts
More file actions
52 lines (44 loc) · 1.22 KB
/
mock.d.ts
File metadata and controls
52 lines (44 loc) · 1.22 KB
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
import fs from 'node:fs';
import eslint, { ESLint } from 'eslint';
import prettier from 'prettier';
import { ESLintConfig } from 'prettier-eslint';
type Fs = typeof fs;
export interface FsMock extends Fs {
readFileSync: jest.Mock<string, [string?]>;
}
export type ESLintCalculateConfigForFile = ESLint['calculateConfigForFile'];
export type ESLintLintText = ESLint['lintText'];
export interface MockESLint extends ESLint {
_originalLintText: ESLintLintText;
}
export interface ThrowError {
throwError?: Error | null;
}
// prettier-ignore
export interface ESLintMock extends (typeof eslint) {
ESLint: jest.Mock<MockESLint>;
mock: {
calculateConfigForFile: jest.Mock<
Promise<ESLintConfig>,
Parameters<ESLintCalculateConfigForFile>
>;
lintText: jest.Mock<
ReturnType<ESLintLintText>,
Parameters<ESLintLintText>
> &
ThrowError;
};
}
type Prettier = typeof prettier;
export interface PrettierMock extends Prettier {
format: jest.Mock<
ReturnType<typeof prettier.format>,
Parameters<typeof prettier.format>
> &
ThrowError;
resolveConfig: jest.Mock<
ReturnType<typeof prettier.resolveConfig>,
Parameters<typeof prettier.resolveConfig>
> &
ThrowError;
}