diff options
author | 2023-01-11 00:59:20 +0800 | |
---|---|---|
committer | 2023-01-11 00:59:20 +0800 | |
commit | 2263e889cc68254d3ce08894a1f719ab4ac45d94 (patch) | |
tree | 28414467fa56c5f35819c42f6329842096ca8fc3 /packages/integrations/node/test/api-route.test.js | |
parent | 4f760cea632bc29d726f52dbb6737b3692aae6e1 (diff) | |
download | astro-2263e889cc68254d3ce08894a1f719ab4ac45d94.tar.gz astro-2263e889cc68254d3ce08894a1f719ab4ac45d94.tar.zst astro-2263e889cc68254d3ce08894a1f719ab4ac45d94.zip |
can jump 404 when that page does not exist (#5701)
Diffstat (limited to 'packages/integrations/node/test/api-route.test.js')
-rw-r--r-- | packages/integrations/node/test/api-route.test.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/integrations/node/test/api-route.test.js b/packages/integrations/node/test/api-route.test.js index 2cc15c761..39ba10dbf 100644 --- a/packages/integrations/node/test/api-route.test.js +++ b/packages/integrations/node/test/api-route.test.js @@ -1,5 +1,5 @@ import nodejs from '../dist/index.js'; -import { loadFixture, createRequestAndResponse, toPromise } from './test-utils.js'; +import { loadFixture, createRequestAndResponse } from './test-utils.js'; import { expect } from 'chai'; describe('API routes', () => { @@ -17,18 +17,21 @@ describe('API routes', () => { it('Can get the request body', async () => { const { handler } = await import('./fixtures/api-route/dist/server/entry.mjs'); - let { req, res, done } = createRequestAndResponse({ method: 'POST', url: '/recipes', }); handler(req, res); - req.send(JSON.stringify({ id: 2 })); + req.send(JSON.stringify({ id: 2 })); + let [buffer] = await done; + let json = JSON.parse(buffer.toString('utf-8')); + expect(json.length).to.equal(1); + expect(json[0].name).to.equal('Broccoli Soup'); }); |