Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/fetch

Package Overview
Dependencies
Maintainers
1
Versions
475
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/fetch - npm Package Compare versions

Comparing version 0.4.5-alpha-20220925232816-030a991 to 0.4.5-alpha-20220925233002-c4d7b92

2

CHANGELOG.md
# @whatwg-node/fetch
## 0.4.5-alpha-20220925232816-030a991
## 0.4.5-alpha-20220925233002-c4d7b92

@@ -5,0 +5,0 @@ ### Patch Changes

{
"name": "@whatwg-node/fetch",
"version": "0.4.5-alpha-20220925232816-030a991",
"version": "0.4.5-alpha-20220925233002-c4d7b92",
"description": "Cross Platform Smart Fetch Ponyfill",

@@ -5,0 +5,0 @@ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",

import { createFetch } from '@whatwg-node/fetch';
describe('getFormDataMethod', () => {
['fieldsFirst:true', 'fieldsFirst:false'].forEach((fieldsFirstFlag) => {
const fetchAPI = createFetch({
formDataLimits: {
fieldsFirst: fieldsFirstFlag === 'fieldsFirst:true',
}
['fieldsFirst:true', 'fieldsFirst:false'].forEach(fieldsFirstFlag => {
const fetchAPI = createFetch({
formDataLimits: {
fieldsFirst: fieldsFirstFlag === 'fieldsFirst:true',
},
});
describe(fieldsFirstFlag, () => {
it('should parse fields correctly', async () => {
const formData = new fetchAPI.FormData();
formData.append('greetings', 'Hello world!');
formData.append('bye', 'Goodbye world!');
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
describe(fieldsFirstFlag, () => {
it('should parse fields correctly', async () => {
const formData = new fetchAPI.FormData();
formData.append('greetings', 'Hello world!');
formData.append('bye', 'Goodbye world!');
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
const formdata = await request.formData();
expect(formdata.get('greetings')).toBe('Hello world!');
expect(formdata.get('bye')).toBe('Goodbye world!');
});
it('should parse and receive text files correctly', async () => {
const formData = new fetchAPI.FormData();
const greetingsFile = new fetchAPI.File(['Hello world!'], 'greetings.txt', { type: 'text/plain' });
const byeFile = new fetchAPI.File(['Goodbye world!'], 'bye.txt', { type: 'text/plain' });
formData.append('greetings', greetingsFile);
formData.append('bye', byeFile);
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
const formdata = await request.formData();
const receivedGreetingsFile = formdata.get('greetings') as File;
const receivedGreetingsText = await receivedGreetingsFile.text();
expect(receivedGreetingsText).toBe('Hello world!');
const receivedByeFile = formdata.get('bye') as File;
const receivedByeText = await receivedByeFile.text();
expect(receivedByeText).toBe('Goodbye world!');
});
})
})
})
const formdata = await request.formData();
expect(formdata.get('greetings')).toBe('Hello world!');
expect(formdata.get('bye')).toBe('Goodbye world!');
});
it('should parse and receive text files correctly', async () => {
const formData = new fetchAPI.FormData();
const greetingsFile = new fetchAPI.File(['Hello world!'], 'greetings.txt', { type: 'text/plain' });
const byeFile = new fetchAPI.File(['Goodbye world!'], 'bye.txt', { type: 'text/plain' });
formData.append('greetings', greetingsFile);
formData.append('bye', byeFile);
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
const formdata = await request.formData();
const receivedGreetingsFile = formdata.get('greetings') as File;
const receivedGreetingsText = await receivedGreetingsFile.text();
expect(receivedGreetingsText).toBe('Hello world!');
const receivedByeFile = formdata.get('bye') as File;
const receivedByeText = await receivedByeFile.text();
expect(receivedByeText).toBe('Goodbye world!');
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc