-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
jest.setup.js
74 lines (63 loc) · 1.17 KB
/
jest.setup.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require('@testing-library/jest-dom');
jest.mock('next/router', () => ({
useRouter: () => ({
push: jest.fn(),
prefetch: jest.fn(),
}),
}));
// Firebase Client
jest.mock('firebase/app', () => ({
__esModule: true,
default: {
initializeApp: jest.fn(),
apps: [],
auth: jest.fn(() => ({
setPersistence: jest.fn(),
signInWithEmailAndPassword: jest.fn(() => ({
user: {
getIdToken: jest.fn(() => '1'),
},
})),
signOut: jest.fn(),
})),
},
}));
jest.mock('firebase/auth');
// Firebase Admin
jest.mock('firebase-admin', () => {
return {
database: {
ServerValue: {
TIMESTAMP: 'TIMESTAMP',
},
},
};
});
jest.mock('@services/firebase/admin', () => {
const set = jest.fn();
const push = jest.fn(() => ({
set,
}));
const ref = jest.fn(() => ({
push,
}));
return {
database: jest.fn(() => ({
ref,
})),
};
});
// AWS
jest.mock('@services/aws/s3', () => {
const promise = jest.fn(() =>
Promise.resolve({
ContentType: 'application/json',
Body: 'Body',
})
);
return {
getObject: jest.fn(() => ({
promise,
})),
};
});