Skip to content

Commit ef6fd0c

Browse files
committed
chore: fix prettier config and reformat
1 parent 4faca6d commit ef6fd0c

File tree

4 files changed

+37
-39
lines changed

4 files changed

+37
-39
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
"arrowParens": "always",
4646
"editor.formatOnSave": true,
4747
"singleQuote": true,
48+
"trailingComma": "es5",
4849
"overrides": [
4950
{
5051
"files": "**/*.ts",
5152
"options": {
5253
"semi": true,
5354
"tabWidth": 4,
5455
"singleQuote": false,
55-
"printWidth": 120
56+
"printWidth": 125
5657
}
5758
}
5859
]

tests/api.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ require('cross-fetch/polyfill')
22

33
async function APIRequest(who) {
44
if (who === 'facebook') {
5-
const call1 = fetch('https://facebook.com/someOtherResource').then(res =>
5+
const call1 = fetch('https://facebook.com/someOtherResource').then((res) =>
66
res.json()
77
)
8-
const call2 = fetch('https://facebook.com').then(res => res.json())
8+
const call2 = fetch('https://facebook.com').then((res) => res.json())
99
return Promise.all([call1, call2])
1010
} else if (who === 'twitter') {
11-
return fetch('https://twitter.com').then(res => res.json())
11+
return fetch('https://twitter.com').then((res) => res.json())
1212
} else {
13-
return fetch('https://google.com').then(res => res.json())
13+
return fetch('https://google.com').then((res) => res.json())
1414
}
1515
}
1616

1717
function APIRequest2(who) {
1818
if (who === 'google') {
19-
return fetch('https://google.com').then(res => res.json())
19+
return fetch('https://google.com').then((res) => res.json())
2020
} else {
2121
return 'no argument provided'
2222
}
@@ -26,7 +26,7 @@ const defaultRequestUri = 'https://randomuser.me/api'
2626

2727
function request(uri = defaultRequestUri) {
2828
return fetch(uri, {})
29-
.then(response => {
29+
.then((response) => {
3030
const contentType = response.headers.get('content-type')
3131

3232
if (/application\/json/.test(contentType)) {
@@ -43,7 +43,7 @@ function request(uri = defaultRequestUri) {
4343

4444
return response
4545
})
46-
.catch(error => {
46+
.catch((error) => {
4747
const errorData = JSON.parse(error)
4848
throw new Error(errorData.error)
4949
})
@@ -53,5 +53,5 @@ module.exports = {
5353
request,
5454
APIRequest,
5555
APIRequest2,
56-
defaultRequestUri
56+
defaultRequestUri,
5757
}

tests/node.test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/**
2-
* @jest-environment node
3-
*/
4-
let DOMException = require('domexception')
5-
6-
it('rejects with a dom exception', () => {
7-
fetch.mockAbort()
8-
expect(fetch('/')).rejects.toThrow(expect.any(DOMException))
9-
})
1+
/**
2+
* @jest-environment node
3+
*/
4+
let DOMException = require('domexception')
5+
6+
it('rejects with a dom exception', () => {
7+
fetch.mockAbort()
8+
expect(fetch('/')).rejects.toThrow(expect.any(DOMException))
9+
})

tests/test.js

+18-21
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('testing mockResponse and alias once', () => {
2929

3030
expect(response).toEqual([
3131
{ secret_data: '12345' },
32-
{ secret_data: '67891' }
32+
{ secret_data: '67891' },
3333
])
3434

3535
expect(fetch.mock.calls.length).toEqual(2)
@@ -61,7 +61,7 @@ describe('testing mockResponse and alias once', () => {
6161

6262
expect(response).toEqual([
6363
{ secret_data: '12345' },
64-
{ secret_data: '67891' }
64+
{ secret_data: '67891' },
6565
])
6666

6767
expect(fetch.mock.calls.length).toEqual(2)
@@ -86,7 +86,7 @@ describe('testing mockResponses', () => {
8686
const response = await APIRequest('facebook')
8787
expect(response).toEqual([
8888
{ name: 'naruto', average_score: 79 },
89-
{ name: 'bleach', average_score: 68 }
89+
{ name: 'bleach', average_score: 68 },
9090
])
9191
expect(fetch.mock.calls.length).toEqual(2)
9292

@@ -157,13 +157,13 @@ describe('request', () => {
157157
const url = 'http://foo.bar/'
158158
const requestInit = {
159159
headers: {
160-
foo: 'bar'
161-
}
160+
foo: 'bar',
161+
},
162162
}
163163
const responseInit = {
164164
headers: {
165-
bing: 'dang'
166-
}
165+
bing: 'dang',
166+
},
167167
}
168168
const response = 'foobarbang'
169169
fetch.mockResponse((input) => {
@@ -180,12 +180,12 @@ describe('request', () => {
180180
it('returns object when response is json', (done) => {
181181
const mockResponse = {
182182
results: [{ gender: 'neutral' }],
183-
info: { seed: '0123456789123456', results: 1, page: 1, version: '1.2' }
183+
info: { seed: '0123456789123456', results: 1, page: 1, version: '1.2' },
184184
}
185185
fetch.mockResponseOnce(JSON.stringify(mockResponse), {
186186
headers: {
187-
'Content-Type': 'application/json'
188-
}
187+
'Content-Type': 'application/json',
188+
},
189189
})
190190

191191
request()
@@ -213,8 +213,8 @@ describe('request', () => {
213213
const contentType = 'text/csv; charset=utf-8'
214214
fetch.mockResponseOnce('csv data', {
215215
headers: {
216-
'Content-Type': contentType
217-
}
216+
'Content-Type': contentType,
217+
},
218218
})
219219

220220
try {
@@ -230,7 +230,7 @@ describe('request', () => {
230230
it('rejects with error data', (done) => {
231231
const errorData = {
232232
error:
233-
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.'
233+
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.',
234234
}
235235
fetch.mockRejectOnce(JSON.stringify(errorData))
236236

@@ -267,7 +267,7 @@ describe('request', () => {
267267
it('rejects with function', async () => {
268268
const errorData = {
269269
error:
270-
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.'
270+
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.',
271271
}
272272
fetch.mockRejectOnce(() => Promise.reject(JSON.stringify(errorData)))
273273
return expect(request()).rejects.toThrow(errorData.error)
@@ -276,7 +276,7 @@ describe('request', () => {
276276
it('rejects with function and timeout', async () => {
277277
const errorData = {
278278
error:
279-
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.'
279+
'Uh oh, something has gone wrong. Please tweet us @randomapi about the issue. Thank you.',
280280
}
281281
fetch.mockRejectOnce(
282282
() =>
@@ -312,7 +312,7 @@ describe('request', () => {
312312
headers: { ding: 'dang' },
313313
status: 201,
314314
statusText: 'text',
315-
url: 'http://foo'
315+
url: 'http://foo',
316316
}),
317317
{ headers: { bash: 'bang' } }
318318
)
@@ -328,7 +328,7 @@ describe('request', () => {
328328

329329
it('resolves with mock response headers and function returning string', async () => {
330330
fetch.mockResponseOnce(() => Promise.resolve('ok'), {
331-
headers: { ding: 'dang' }
331+
headers: { ding: 'dang' },
332332
})
333333
return expect(
334334
fetch('https://bar', {}).then((response) => response.headers.get('ding'))
@@ -372,10 +372,7 @@ describe('conditional mocking', () => {
372372
})
373373
it('dont mock once then mock twice', async () => {
374374
const otherResponse = 'other response'
375-
fetch
376-
.dontMockOnce()
377-
.once(otherResponse)
378-
.once(otherResponse)
375+
fetch.dontMockOnce().once(otherResponse).once(otherResponse)
379376

380377
await expectUnmocked()
381378
await expectMocked(defaultRequestUri, otherResponse)

0 commit comments

Comments
 (0)