v0.3.0 - Profiles (Check the description for changes)

A lot has been renovated and some small things has been added to v0.3.0:
	* Added profiles (`getProfile`, `setProfile`, `setDefaults`)
	* Renamed `Collection` to `MemoryCollection`
	* Made `wumpfetch.userAgent` read-only
	* Renamed `__test__` to `tests`
	* Removed the `dist` folder
	* Changed the tab size from `4` to `2` in the declarations file
	and wumpfetch TS test file
	* Added JSdoc to `WumpRequest` and `WumpResponse`
	* Fixed up some of the weird spacing in `WumpRequest` and
	`WumpResponse`
	* Cleaned up all test files
This commit is contained in:
Wessel T
2019-08-26 16:52:34 +02:00
parent fc74329800
commit dd302b983e
31 changed files with 965 additions and 864 deletions

16
tests/main.js Normal file
View File

@@ -0,0 +1,16 @@
const util = require('util');
const wump = require('../lib');
console.log(`Using wumpfetch v${wump.version} [${wump.userAgent}]`);
;(async() => {
const requests = [
await wump({ url: 'https://httpbin.org/get', parse: 'json' }).send(),
await wump('https://httpbin.org/get', { chain: false }),
await wump('https://httpbin.org/post', { chain: false, method: 'POST', body: { title: 'Wump', body: 'is cool', userId: 1 } })
];
console.log(`Test 1: \n${util.inspect(requests[0].body)}\n`);
console.log(`Test 2: \n${util.inspect(requests[1].json())}\n`);
console.log(`Test 3: \n${util.inspect(requests[2].parse())}\n`);
})();

22
tests/profiles.js Normal file
View File

@@ -0,0 +1,22 @@
const wump = require('../lib');
const util = require('util');
console.log(`Using wumpfetch v${wump.version} [${wump.userAgent}]`);
const profileData = {
headers: {
'Authorization': 'Wumper'
}
};
wump.setProfile('main', profileData);
console.log(wump.getProfile('main'));
wump.setDefaults(profileData);
console.log(wump.getProfile('__default__'));
;(async () => {
const req = await wump({ url: 'https://httpbin.org/get' }).send();
console.log(`Test 1: \n${util.inspect(req.parse())}`);
})();

14
tests/wumpfetch-tests.ts Normal file
View File

@@ -0,0 +1,14 @@
import wump from '../lib';
import util from 'util';
console.log(`Using wumpfetch v${wump.version} [${wump.userAgent}]`);
;(async() => {
const requests = [
await wump('https://httpbin.org/get', 'GET').send(),
await wump('https://httpbin.org/get', { method: 'GET', chaining: false })
];
console.log(`Test 1: \n${util.inspect(requests[0].parse())}\n`);
console.log(`Test 2: \n${util.inspect(requests[1].json())}\n`);
})();