Skip to content

Commit

Permalink
chore: no more inline snapshots due to prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
maxholman committed Nov 8, 2023
1 parent a8be044 commit 9003a94
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 236 deletions.
27 changes: 27 additions & 0 deletions __tests__/__snapshots__/client.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Client 200 OK! 1`] = `
[
1,
2,
3,
]
`;

exports[`Client 404 1`] = `[Error: Not Found]`;

exports[`Client Headers 1`] = `
{
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "node",
"x-async": "Bearer 1234567890",
"x-build-id": "test/123",
"x-func": "hello",
"x-merged": "hello",
}
`;
70 changes: 70 additions & 0 deletions __tests__/__snapshots__/fetcher.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Fetcher 200 OK! 1`] = `
{
"body": [
1,
2,
3,
],
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`;
exports[`Fetcher 204 1`] = `
{
"body": "",
"ok": true,
"status": 204,
"statusText": "No Content",
"url": Any<URL>,
}
`;
exports[`Fetcher 404 1`] = `
{
"body": "<h1>Not Found</h1>",
"ok": false,
"status": 404,
"statusText": "Not Found",
"url": Any<URL>,
}
`;
exports[`Fetcher Custom options iso fetcher 1`] = `
{
"body": {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "node",
"x-fetcher": "custom",
},
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`;
exports[`Fetcher Custom timeout iso fetcher 1`] = `[TimeoutError: Request timed out]`;
exports[`Fetcher JSON Error 1`] = `
{
"body": {
"code": 9,
"message": "Data should be array",
"status": "FAILED_PRECONDITION",
},
"ok": false,
"status": 400,
"statusText": "Bad Request",
"url": Any<URL>,
}
`;
31 changes: 3 additions & 28 deletions __tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,11 @@ describe('Client', () => {
test('200 OK!', async () => {
const response = await client.json(new Fake200Command());

expect(response).toMatchInlineSnapshot(`
[
1,
2,
3,
]
`);
expect(response).toMatchSnapshot();
});

test('404', async () => {
await expect(
client.json(new Fake404Command()),
).rejects.toMatchInlineSnapshot(
// eslint-disable-next-line quotes
`[Error: Not Found]`,
);
await expect(client.json(new Fake404Command())).rejects.toMatchSnapshot();
});

test('JSON Error', async () => {
Expand All @@ -106,21 +95,7 @@ describe('Client', () => {
},
});

expect(response).toMatchInlineSnapshot(`
{
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "undici",
"x-async": "Bearer 1234567890",
"x-build-id": "test/123",
"x-func": "hello",
"x-merged": "hello",
}
`);
expect(response).toMatchSnapshot();
});

afterAll((done) => {
Expand Down
107 changes: 16 additions & 91 deletions __tests__/fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,9 @@ describe('Fetcher', () => {
url: new URL('/200', base),
});

expect(response).toMatchInlineSnapshot(
{
url: expect.any(URL),
},
`
{
"body": [
1,
2,
3,
],
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`,
);
expect(response).toMatchSnapshot({
url: expect.any(URL),
});
});

test('204', async () => {
Expand All @@ -47,20 +32,9 @@ describe('Fetcher', () => {
url: new URL('/204', base),
});

expect(response).toMatchInlineSnapshot(
{
url: expect.any(URL),
},
`
{
"body": "",
"ok": true,
"status": 204,
"statusText": "No Content",
"url": Any<URL>,
}
`,
);
expect(response).toMatchSnapshot({
url: expect.any(URL),
});
});

test('JSON Error', async () => {
Expand All @@ -69,24 +43,9 @@ describe('Fetcher', () => {
method: 'get',
url: new URL('/json-error', base),
}),
).toMatchInlineSnapshot(
{
url: expect.any(URL),
},
`
{
"body": {
"code": 9,
"message": "Data should be array",
"status": "FAILED_PRECONDITION",
},
"ok": false,
"status": 400,
"statusText": "Bad Request",
"url": Any<URL>,
}
`,
);
).toMatchSnapshot({
url: expect.any(URL),
});
});

test('404', async () => {
Expand All @@ -95,20 +54,9 @@ describe('Fetcher', () => {
method: 'get',
url: new URL('/404', base),
}),
).toMatchInlineSnapshot(
{
url: expect.any(URL),
},
`
{
"body": "<h1>Not Found</h1>",
"ok": false,
"status": 404,
"statusText": "Not Found",
"url": Any<URL>,
}
`,
);
).toMatchSnapshot({
url: expect.any(URL),
});
});

test('Custom options iso fetcher', async () => {
Expand All @@ -123,29 +71,9 @@ describe('Fetcher', () => {
method: 'get',
url: new URL('/my-headers', base),
}),
).toMatchInlineSnapshot(
{
url: expect.any(URL),
},
`
{
"body": {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "undici",
"x-fetcher": "custom",
},
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`,
);
).toMatchSnapshot({
url: expect.any(URL),
});
});

test('Custom timeout iso fetcher', async () => {
Expand All @@ -158,10 +86,7 @@ describe('Fetcher', () => {
method: 'get',
url: new URL('/unresponsive', base),
}),
).rejects.toMatchInlineSnapshot(
// eslint-disable-next-line quotes
`[TimeoutError: Request timed out]`,
);
).rejects.toMatchSnapshot();
}, 150);

afterAll((done) => {
Expand Down
27 changes: 27 additions & 0 deletions __tests__/legacy/__snapshots__/client.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Client 200 OK! 1`] = `
[
1,
2,
3,
]
`;

exports[`Client 404 1`] = `[Error: Not Found]`;

exports[`Client Headers 1`] = `
{
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "node",
"x-async": "Bearer 1234567890",
"x-build-id": "test/123",
"x-func": "hello",
"x-merged": "hello",
}
`;
70 changes: 70 additions & 0 deletions __tests__/legacy/__snapshots__/fetcher.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Fetcher 200 OK! 1`] = `
{
"body": [
1,
2,
3,
],
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`;
exports[`Fetcher 204 1`] = `
{
"body": "",
"ok": true,
"status": 204,
"statusText": "No Content",
"url": Any<URL>,
}
`;
exports[`Fetcher 404 1`] = `
{
"body": "<h1>Not Found</h1>",
"ok": false,
"status": 404,
"statusText": "Not Found",
"url": Any<URL>,
}
`;
exports[`Fetcher Custom options iso fetcher 1`] = `
{
"body": {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"accept-language": "*",
"connection": "keep-alive",
"host": "redacted",
"sec-fetch-mode": "cors",
"user-agent": "node",
"x-fetcher": "custom",
},
"ok": true,
"status": 200,
"statusText": "OK",
"url": Any<URL>,
}
`;
exports[`Fetcher Custom timeout iso fetcher 1`] = `[TimeoutError: Request timed out]`;
exports[`Fetcher JSON Error 1`] = `
{
"body": {
"code": 9,
"message": "Data should be array",
"status": "FAILED_PRECONDITION",
},
"ok": false,
"status": 400,
"statusText": "Bad Request",
"url": Any<URL>,
}
`;
Loading

0 comments on commit 9003a94

Please sign in to comment.