Skip to content

Commit

Permalink
Another test
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Apr 26, 2024
1 parent 3ec42de commit 5bf5dd4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/integrations/web-vitals/test/basics.test.js
Expand Up @@ -86,6 +86,14 @@ describe('Web Vitals integration basics', () => {
assert.equal(consoleErrorMock.calls.length, 2);
});

it('validates data sent to the injected endpoint with Zod', async () => {
const res = await fixture.fetch('/_/astro-vitals', { method: 'POST', body: '[{}]' });
assert.equal(res.status, 200);
const call = consoleErrorMock.calls[0][0];
assert.ok(call instanceof Error);
assert.equal(call.name, 'ZodError');
});

it('inserts data via the injected endpoint', async () => {
const res = await fixture.fetch('/_/astro-vitals', {
method: 'POST',
Expand All @@ -104,7 +112,7 @@ describe('Web Vitals integration basics', () => {
assert.equal(
consoleErrorMock.calls.length,
0,
'Endpoint logged errors:\n' + consoleErrorMock.calls[0].join(' ')
'Endpoint logged errors:\n' + consoleErrorMock.calls[0]?.join(' ')
);
});
});

0 comments on commit 5bf5dd4

Please sign in to comment.