1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-07-01 10:43:38 +00:00

Updated everything

This commit is contained in:
MatteZ02
2019-09-15 09:18:33 +03:00
parent 9d7e55b5ee
commit e4e99d76c9
1064 changed files with 277 additions and 171372 deletions

View File

@ -1,47 +0,0 @@
/**
* @jest-environment node
*/
const fs = require('fs');
const { Snekfetch } = require('../interop');
const resolve = (x) => require.resolve(x);
test('node/file get', () => {
const original = fs.readFileSync(resolve('../../package.json')).toString();
return Snekfetch.get(`file://${resolve('../../package.json')}`)
.then((res) => {
expect(res.text).toBe(original);
});
});
test('node/file post', () => {
const content = 'wow this is a\n\ntest!!';
const file = './test_file_post.txt';
return Snekfetch.post(`file://${file}`)
.send(content)
.then(() => Snekfetch.get(`file://${file}`))
.then((res) => {
expect(res.text).toBe(content);
})
.then(() => {
fs.unlinkSync(file);
});
});
test('node/file delete', () => {
const file = './test_file_delete.txt';
fs.closeSync(fs.openSync(file, 'w'));
expect(fs.existsSync(file)).toBe(true);
return Snekfetch.delete(`file://${file}`)
.then(() => {
expect(fs.existsSync(file)).toBe(false);
});
});
test('node/file invalid method', () => {
expect(() => {
Snekfetch.options('file:///dev/urandom');
}).toThrow(/Invalid request method for file:/);
});

View File

@ -1,7 +0,0 @@
/**
* @jest-environment node
*/
global.HTTP_VERSION = 1;
require('./main');

View File

@ -1,7 +0,0 @@
/**
* @jest-environment node
*/
global.HTTP_VERSION = 2;
require('./main');

View File

@ -1,26 +0,0 @@
const fs = require('fs');
const { Snekfetch, TestRoot } = require('../interop');
require('../main');
test('node/pipe get', (done) => {
Snekfetch.get(`${TestRoot}/get`)
.pipe(fs.createWriteStream('/dev/null'))
.on('finish', done);
});
test('node/FormData json works', () =>
Snekfetch.post(`${TestRoot}/post`)
.attach('object', { a: 1 })
.then((res) => {
const { form } = res.body;
expect(form.object).toBe('{"a":1}');
})
);
test('node/rawsend post', () =>
Snekfetch.post(`${TestRoot}/post`)
.send(Buffer.from('memes')).end()
);

View File

@ -1,10 +0,0 @@
/**
* @jest-environment node
*/
const { SnekfetchSync, TestRoot } = require('../interop');
test('sync get', SnekfetchSync && (() => {
const res = SnekfetchSync.get(`${TestRoot}/get`).end();
expect(res.body).not.toBeUndefined();
}));

View File

@ -1,17 +0,0 @@
const FormData = require('../../src/node/FormData');
const mime = require('../../src/node/mime');
test('node/FormData behaves predictably', () => {
const f = new FormData();
f.append('hello');
f.append('hello', 'world');
expect(f.length).toBe(77);
f.append('meme', 'dream', 'name');
expect(f.length).toBe(210);
});
test('node/mimes behaves predictably', () => {
expect(mime.lookup('js')).toBe('application/javascript');
expect(mime.lookup('nope')).toBe('application/octet-stream');
expect(mime.buffer([0xFF, 0xD8, 0xFF])).toBe('image/jpeg');
});