summaryrefslogtreecommitdiff
path: root/node_modules/snekfetch/test/node/main.js
blob: b811ec913c3a4b8c812f365d864ef0cb30d432a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()
);