Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
upgrade prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Apr 15, 2020
1 parent c04bdd7 commit 3a3b089
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 75 deletions.
34 changes: 17 additions & 17 deletions __tests__/jest-built-ins.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ describe('jest built-ins', () => {
fetch.mock('http://example.com', 200).mock('http://example2.com', 201);
fetch('http://example.com', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example2.com', {
headers: {
test: 'header2'
}
test: 'header2',
},
});
});

Expand All @@ -26,28 +26,28 @@ describe('jest built-ins', () => {
'http://example.com',
{
headers: {
test: 'header'
}
}
test: 'header',
},
},
],
[
'http://example2.com',
{
headers: {
test: 'header2'
}
}
]
test: 'header2',
},
},
],
]);
});
it('exposes `results` property', async () => {
expect(fetch.mock.results).toBeDefined();
expect(fetch.mock.results.length).toEqual(2);
expect(await fetch.mock.results[0].value).toMatchObject({
status: 200
status: 200,
});
expect(await fetch.mock.results[1].value).toMatchObject({
status: 201
status: 201,
});
});
});
Expand All @@ -57,13 +57,13 @@ describe('jest built-ins', () => {
fetch.mock('http://example.com', 200).mock('http://example2.com', 201);
fetch('http://example.com', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example2.com', {
headers: {
test: 'header2'
}
test: 'header2',
},
});
});

Expand Down
84 changes: 42 additions & 42 deletions __tests__/jest-extensions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ describe('jest extensions', () => {
fetch.mock('*', 200);
fetch('http://example.com/path2', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
afterAll(() => fetch.reset());
Expand All @@ -55,24 +55,24 @@ describe('jest extensions', () => {
it('matches with matcher and options', () => {
expect(fetch).toHaveFetched('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

it("doesn't match if matcher but not options is correct", () => {
expect(fetch).not.toHaveFetched('http://example.com/path', {
headers: {
test: 'not-header'
}
test: 'not-header',
},
});
});

it("doesn't match if options but not matcher is correct", () => {
expect(fetch).not.toHaveFetched('http://example-no.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
});
Expand All @@ -81,8 +81,8 @@ describe('jest extensions', () => {
fetch.mock('*', 200);
fetch('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
afterAll(() => fetch.reset());
Expand All @@ -98,24 +98,24 @@ describe('jest extensions', () => {
it('matches with matcher and options', () => {
expect(fetch).toHaveLastFetched('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

it("doesn't match if matcher but not options is correct", () => {
expect(fetch).not.toHaveLastFetched('http://example.com/path', {
headers: {
test: 'not-header'
}
test: 'not-header',
},
});
});

it("doesn't match if options but not matcher is correct", () => {
expect(fetch).not.toHaveLastFetched('http://example-no.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
});
Expand All @@ -125,13 +125,13 @@ describe('jest extensions', () => {
fetch.mock('*', 200);
fetch('http://example1.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example2.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
afterAll(() => fetch.reset());
Expand All @@ -147,24 +147,24 @@ describe('jest extensions', () => {
it('matches with matcher and options', () => {
expect(fetch).toHaveNthFetched(2, 'http://example2.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

it("doesn't match if matcher but not options is correct", () => {
expect(fetch).not.toHaveNthFetched(2, 'http://example2.com/path', {
headers: {
test: 'not-header'
}
test: 'not-header',
},
});
});

it("doesn't match if options but not matcher is correct", () => {
expect(fetch).not.toHaveNthFetched(2, 'http://example-no.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

Expand All @@ -178,13 +178,13 @@ describe('jest extensions', () => {
fetch.mock('*', 200);
fetch('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
afterAll(() => fetch.reset());
Expand All @@ -200,24 +200,24 @@ describe('jest extensions', () => {
it('matches with matcher and options', () => {
expect(fetch).toHaveFetchedTimes(2, 'http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

it("doesn't match if matcher but not options is correct", () => {
expect(fetch).not.toHaveFetchedTimes(2, 'http://example.com/path', {
headers: {
test: 'not-header'
}
test: 'not-header',
},
});
});

it("doesn't match if options but not matcher is correct", () => {
expect(fetch).not.toHaveFetchedTimes(2, 'http://example-no.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});

Expand All @@ -236,13 +236,13 @@ describe('jest extensions', () => {
fetch.mock('http://example2.com/path', 200, { repeat: 2 });
fetch('http://example.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
fetch('http://example2.com/path', {
headers: {
test: 'header'
}
test: 'header',
},
});
});
afterAll(() => fetch.reset());
Expand Down
14 changes: 7 additions & 7 deletions jest-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ expect.extend({
}
return {
pass: false,
message: () => `fetch should have been called with ${url}`
message: () => `fetch should have been called with ${url}`,
};
},
toHaveLastFetched: (fetchMock, url, options) => {
const allCalls = fetchMock.calls();
if (!allCalls.length) {
return {
pass: false,
message: () => `No calls made to fetch`
message: () => `No calls made to fetch`,
};
}
const lastCall = [...allCalls].pop();
Expand All @@ -24,7 +24,7 @@ expect.extend({
return {
pass: false,
message: () =>
`Last call to fetch should have had a URL of ${url} but was ${lastCall.url}`
`Last call to fetch should have had a URL of ${url} but was ${lastCall.url}`,
};
},

Expand All @@ -37,7 +37,7 @@ expect.extend({
return {
pass: false,
message: () =>
`${n}th call to fetch should have had a URL of ${url} but was ${nthCall.url}`
`${n}th call to fetch should have had a URL of ${url} but was ${nthCall.url}`,
};
},

Expand All @@ -49,7 +49,7 @@ expect.extend({
return {
pass: false,
message: () =>
`fetch should have been called with a URL of ${url} ${times} times, but it was called ${calls.length} times`
`fetch should have been called with a URL of ${url} ${times} times, but it was called ${calls.length} times`,
};
},

Expand All @@ -63,7 +63,7 @@ expect.extend({
message: () =>
`fetch has not been called the expected number of times ${
matcher ? `for ${matcher}` : 'in total'
}`
}`,
};
}
},
});
10 changes: 5 additions & 5 deletions jestify.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*global jest*/
require('./jest-extensions');

const jestify = fetchMockInstance => {
const jestify = (fetchMockInstance) => {
const jestifiedInstance = new Proxy(fetchMockInstance, {
get: (originalFetchMock, name) => {
if (name === 'sandbox') {
return new Proxy(originalFetchMock[name], {
apply: (func, thisArg, args) => {
const sandboxedFetchMock = func.apply(originalFetchMock, args);
return jestify(sandboxedFetchMock);
}
},
});
}
return originalFetchMock[name];
}
},
});

// spy on the fetch handler so we can use all the
Expand All @@ -23,7 +23,7 @@ const jestify = fetchMockInstance => {
// make sure all the jest expectation helpers can find what they need on fetchMock.mock
Object.assign(jestifiedInstance.mock, jestifiedInstance.fetchHandler.mock);

['_isMockFunction', 'mockName', 'getMockName'].forEach(prop => {
['_isMockFunction', 'mockName', 'getMockName'].forEach((prop) => {
jestifiedInstance[prop] = jestifiedInstance.fetchHandler[prop];
});

Expand Down Expand Up @@ -101,4 +101,4 @@ const jestify = fetchMockInstance => {
return jestifiedInstance;
};

module.exports = fetchMock => jestify(fetchMock);
module.exports = (fetchMock) => jestify(fetchMock);
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"eslint-plugin-prettier": "^3.1.1",
"jest": "^25.0.0",
"node-fetch": "^2.6.0",
"prettier": "^1.18.2"
"prettier": "^2.0.4"
}
}

0 comments on commit 3a3b089

Please sign in to comment.