smartrequest/test/test.ts

28 lines
857 B
TypeScript
Raw Normal View History

import { tap, expect } from '@pushrocks/tapbundle';
2017-01-28 23:51:47 +00:00
2018-06-13 20:34:49 +00:00
import * as smartrequest from '../ts/index';
2017-01-28 23:51:47 +00:00
2017-06-09 19:48:16 +00:00
tap.test('should request a html document over https', async () => {
2018-06-18 22:30:40 +00:00
await expect(smartrequest.getJson('https://encrypted.google.com/'))
2018-06-13 20:34:49 +00:00
.to.eventually.property('body')
.be.a('string');
});
2017-01-28 23:51:47 +00:00
2017-06-09 19:48:16 +00:00
tap.test('should request a JSON document over https', async () => {
2018-06-18 22:30:40 +00:00
await expect(smartrequest.getJson('https://jsonplaceholder.typicode.com/posts/1'))
2018-06-13 20:34:49 +00:00
.to.eventually.property('body')
.property('id')
.equal(1);
});
2017-01-28 23:51:47 +00:00
2017-06-09 19:48:16 +00:00
tap.test('should post a JSON document over http', async () => {
2018-06-18 22:30:40 +00:00
await expect(smartrequest.postJson('http://md5.jsontest.com/?text=example_text'))
2018-06-13 20:34:49 +00:00
.to.eventually.property('body')
.property('md5')
.equal('fa4c6baa0812e5b5c80ed8885e55a8a6');
});
2017-06-09 19:48:16 +00:00
tap.test('should deal with unix socks', async () => {});
2018-06-13 20:34:49 +00:00
tap.start();