Skip to content

Commit

Permalink
test: tests fotr all new body types pass
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 29, 2024
1 parent 3189c1c commit 908acbc
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ describe('response construction', () => {
}

it('respond with Blob', async () => {
const blobParts = ['<q id="a"><span id="b">hey!</span></q>'];
const body = new Blob(blobParts, { type: 'text/html' });
const blobParts = ['test value'];
const body = new Blob(blobParts);
fm.route('*', body);
const res = await fm.fetchHandler('http://a.com');
expect(res.status).to.equal(200);
Expand Down Expand Up @@ -167,30 +167,32 @@ describe('response construction', () => {
});

it('respond with ReadableStream', async () => {
const body = ReadableStream.from(['a', 'b']);
const body = new Blob(['test value']).stream();
fm.route('*', body);
const res = await fm.fetchHandler('http://a.com');
expect(res.status).to.equal(200);
const receivedData = await res.text();
console.log(receivedData);
expect(receivedData).to.eql(body);
expect(receivedData).to.eql('test value');
});
});
it('respond with FormData', async () => {
const body = new FormData();
body.append('field', 'value');
fm.route('*', body);
const res = await fm.fetchHandler('http://a.com');
expect(res.status).to.equal(200);
const receivedData = await res.blob();
const receivedData = await res.formData();
console.log(receivedData);
expect(receivedData).to.eql(body);
});
it('respond with URLSearchParams', async () => {
const body = new URLSearchParams();
body.append('field', 'value');
fm.route('*', body);
const res = await fm.fetchHandler('http://a.com');
expect(res.status).to.equal(200);
const receivedData = await res.blob();
expect(receivedData).to.eql(body);
const receivedData = await res.formData();
expect(receivedData.get('field')).to.equal('value');
});

it('should set the url property on responses', async () => {
Expand Down

0 comments on commit 908acbc

Please sign in to comment.