Skip to content

Commit 1c48ade

Browse files
authored
fix: remove axios default headers (#2177)
Signed-off-by: Adam Setch <[email protected]>
1 parent cac7b4d commit 1c48ade

File tree

5 files changed

+134
-211
lines changed

5 files changed

+134
-211
lines changed

src/renderer/utils/api/__snapshots__/client.test.ts.snap

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/renderer/utils/api/__snapshots__/request.test.ts.snap

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/renderer/utils/api/client.test.ts

Lines changed: 78 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,31 @@ describe('renderer/utils/api/client.ts', () => {
3535

3636
expect(axios).toHaveBeenCalledWith({
3737
url: 'https://api.github.com/user',
38+
headers: {
39+
Accept: 'application/json',
40+
Authorization: 'token decrypted',
41+
'Cache-Control': '',
42+
'Content-Type': 'application/json',
43+
},
3844
method: 'GET',
3945
data: {},
4046
});
41-
42-
expect(axios.defaults.headers.common).toMatchSnapshot();
4347
});
4448

4549
it('should fetch authenticated user - enterprise', async () => {
4650
await getAuthenticatedUser(mockEnterpriseHostname, mockToken);
4751

4852
expect(axios).toHaveBeenCalledWith({
4953
url: 'https://example.com/api/v3/user',
54+
headers: {
55+
Accept: 'application/json',
56+
Authorization: 'token decrypted',
57+
'Cache-Control': '',
58+
'Content-Type': 'application/json',
59+
},
5060
method: 'GET',
5161
data: {},
5262
});
53-
54-
expect(axios.defaults.headers.common).toMatchSnapshot();
5563
});
5664
});
5765

@@ -61,23 +69,31 @@ describe('renderer/utils/api/client.ts', () => {
6169

6270
expect(axios).toHaveBeenCalledWith({
6371
url: 'https://api.github.com/notifications',
72+
headers: {
73+
Accept: 'application/json',
74+
Authorization: 'token decrypted',
75+
'Cache-Control': 'no-cache',
76+
'Content-Type': 'application/json',
77+
},
6478
method: 'HEAD',
6579
data: {},
6680
});
67-
68-
expect(axios.defaults.headers.common).toMatchSnapshot();
6981
});
7082

7183
it('should fetch notifications head - enterprise', async () => {
7284
await headNotifications(mockEnterpriseHostname, mockToken);
7385

7486
expect(axios).toHaveBeenCalledWith({
7587
url: 'https://example.com/api/v3/notifications',
88+
headers: {
89+
Accept: 'application/json',
90+
Authorization: 'token decrypted',
91+
'Cache-Control': 'no-cache',
92+
'Content-Type': 'application/json',
93+
},
7694
method: 'HEAD',
7795
data: {},
7896
});
79-
80-
expect(axios.defaults.headers.common).toMatchSnapshot();
8197
});
8298
});
8399

@@ -95,11 +111,15 @@ describe('renderer/utils/api/client.ts', () => {
95111

96112
expect(axios).toHaveBeenCalledWith({
97113
url: 'https://api.github.com/notifications?participating=true',
114+
headers: {
115+
Accept: 'application/json',
116+
Authorization: 'token decrypted',
117+
'Cache-Control': 'no-cache',
118+
'Content-Type': 'application/json',
119+
},
98120
method: 'GET',
99121
data: {},
100122
});
101-
102-
expect(axios.defaults.headers.common).toMatchSnapshot();
103123
});
104124

105125
it('should list notifications for user - github cloud - fetchAllNotifications false', async () => {
@@ -115,11 +135,15 @@ describe('renderer/utils/api/client.ts', () => {
115135

116136
expect(axios).toHaveBeenCalledWith({
117137
url: 'https://api.github.com/notifications?participating=true',
138+
headers: {
139+
Accept: 'application/json',
140+
Authorization: 'token decrypted',
141+
'Cache-Control': 'no-cache',
142+
'Content-Type': 'application/json',
143+
},
118144
method: 'GET',
119145
data: {},
120146
});
121-
122-
expect(axios.defaults.headers.common).toMatchSnapshot();
123147
});
124148

125149
it('should list notifications for user - github enterprise server', async () => {
@@ -134,11 +158,15 @@ describe('renderer/utils/api/client.ts', () => {
134158

135159
expect(axios).toHaveBeenCalledWith({
136160
url: 'https://github.gitify.io/api/v3/notifications?participating=true',
161+
headers: {
162+
Accept: 'application/json',
163+
Authorization: 'token decrypted',
164+
'Cache-Control': 'no-cache',
165+
'Content-Type': 'application/json',
166+
},
137167
method: 'GET',
138168
data: {},
139169
});
140-
141-
expect(axios.defaults.headers.common).toMatchSnapshot();
142170
});
143171
});
144172

@@ -152,11 +180,15 @@ describe('renderer/utils/api/client.ts', () => {
152180

153181
expect(axios).toHaveBeenCalledWith({
154182
url: `https://api.github.com/notifications/threads/${mockThreadId}`,
183+
headers: {
184+
Accept: 'application/json',
185+
Authorization: 'token decrypted',
186+
'Cache-Control': '',
187+
'Content-Type': 'application/json',
188+
},
155189
method: 'PATCH',
156190
data: {},
157191
});
158-
159-
expect(axios.defaults.headers.common).toMatchSnapshot();
160192
});
161193

162194
it('should mark notification thread as read - enterprise', async () => {
@@ -168,11 +200,15 @@ describe('renderer/utils/api/client.ts', () => {
168200

169201
expect(axios).toHaveBeenCalledWith({
170202
url: `https://example.com/api/v3/notifications/threads/${mockThreadId}`,
203+
headers: {
204+
Accept: 'application/json',
205+
Authorization: 'token decrypted',
206+
'Cache-Control': '',
207+
'Content-Type': 'application/json',
208+
},
171209
method: 'PATCH',
172210
data: {},
173211
});
174-
175-
expect(axios.defaults.headers.common).toMatchSnapshot();
176212
});
177213
});
178214

@@ -186,11 +222,15 @@ describe('renderer/utils/api/client.ts', () => {
186222

187223
expect(axios).toHaveBeenCalledWith({
188224
url: `https://api.github.com/notifications/threads/${mockThreadId}`,
225+
headers: {
226+
Accept: 'application/json',
227+
Authorization: 'token decrypted',
228+
'Cache-Control': '',
229+
'Content-Type': 'application/json',
230+
},
189231
method: 'DELETE',
190232
data: {},
191233
});
192-
193-
expect(axios.defaults.headers.common).toMatchSnapshot();
194234
});
195235

196236
it('should mark notification thread as done - enterprise', async () => {
@@ -202,11 +242,15 @@ describe('renderer/utils/api/client.ts', () => {
202242

203243
expect(axios).toHaveBeenCalledWith({
204244
url: `https://example.com/api/v3/notifications/threads/${mockThreadId}`,
245+
headers: {
246+
Accept: 'application/json',
247+
Authorization: 'token decrypted',
248+
'Cache-Control': '',
249+
'Content-Type': 'application/json',
250+
},
205251
method: 'DELETE',
206252
data: {},
207253
});
208-
209-
expect(axios.defaults.headers.common).toMatchSnapshot();
210254
});
211255
});
212256

@@ -220,11 +264,15 @@ describe('renderer/utils/api/client.ts', () => {
220264

221265
expect(axios).toHaveBeenCalledWith({
222266
url: `https://api.github.com/notifications/threads/${mockThreadId}/subscription`,
267+
headers: {
268+
Accept: 'application/json',
269+
Authorization: 'token decrypted',
270+
'Cache-Control': '',
271+
'Content-Type': 'application/json',
272+
},
223273
method: 'PUT',
224274
data: { ignored: true },
225275
});
226-
227-
expect(axios.defaults.headers.common).toMatchSnapshot();
228276
});
229277

230278
it('should ignore notification thread subscription - enterprise', async () => {
@@ -236,11 +284,15 @@ describe('renderer/utils/api/client.ts', () => {
236284

237285
expect(axios).toHaveBeenCalledWith({
238286
url: `https://example.com/api/v3/notifications/threads/${mockThreadId}/subscription`,
287+
headers: {
288+
Accept: 'application/json',
289+
Authorization: 'token decrypted',
290+
'Cache-Control': '',
291+
'Content-Type': 'application/json',
292+
},
239293
method: 'PUT',
240294
data: { ignored: true },
241295
});
242-
243-
expect(axios.defaults.headers.common).toMatchSnapshot();
244296
});
245297
});
246298

0 commit comments

Comments
 (0)