mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
[ci] format
This commit is contained in:
parent
cf8a7e933d
commit
a36d51d433
3 changed files with 7 additions and 5 deletions
|
@ -217,7 +217,7 @@ async function handleRequest(
|
||||||
if (!(req.method === 'GET' || req.method === 'HEAD')) {
|
if (!(req.method === 'GET' || req.method === 'HEAD')) {
|
||||||
let bytes: Uint8Array[] = [];
|
let bytes: Uint8Array[] = [];
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
req.on('data', part => {
|
req.on('data', (part) => {
|
||||||
bytes.push(part);
|
bytes.push(part);
|
||||||
});
|
});
|
||||||
req.on('end', resolve);
|
req.on('end', resolve);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { expect } from 'chai';
|
||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { FormData, File } from 'node-fetch'
|
import { FormData, File } from 'node-fetch';
|
||||||
|
|
||||||
describe('API routes', () => {
|
describe('API routes', () => {
|
||||||
/** @type {import('./test-utils').Fixture} */
|
/** @type {import('./test-utils').Fixture} */
|
||||||
|
|
|
@ -56,14 +56,16 @@ describe('API routes in SSR', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can be passed binary data from multipart formdata', async () => {
|
it('Can be passed binary data from multipart formdata', async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const raw = await fs.promises.readFile(new URL('./fixtures/ssr-api-route/src/images/penguin.jpg', import.meta.url));
|
const raw = await fs.promises.readFile(
|
||||||
|
new URL('./fixtures/ssr-api-route/src/images/penguin.jpg', import.meta.url)
|
||||||
|
);
|
||||||
const file = new File([raw], 'penguin.jpg', { type: 'text/jpg' });
|
const file = new File([raw], 'penguin.jpg', { type: 'text/jpg' });
|
||||||
formData.set('file', file, 'penguin.jpg');
|
formData.set('file', file, 'penguin.jpg');
|
||||||
|
|
||||||
const res = await fixture.fetch('/binary', {
|
const res = await fixture.fetch('/binary', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(res.status).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
|
|
Loading…
Reference in a new issue