Skip to content

Instantly share code, notes, and snippets.

@josherich
Last active June 29, 2019 14:43
Show Gist options
  • Save josherich/6070af07372776b9c00e40c89307816a to your computer and use it in GitHub Desktop.
Save josherich/6070af07372776b9c00e40c89307816a to your computer and use it in GitHub Desktop.
test utils
// https://github.com/sindresorhus/query-string/blob/master/test/extract.js
import test from 'ava';
import queryString from '..';
test('handles strings not containing query string', t => {
t.is(queryString.extract('https://foo.bar'), '');
t.is(queryString.extract('https://foo.bar#top'), '');
t.is(queryString.extract(''), '');
});
test('throws for invalid values', t => {
t.throws(() => {
queryString.extract(null);
}, TypeError);
t.throws(() => {
queryString.extract(undefined);
}, TypeError);
});
const supertest = require('supertest');
let server;
beforeAll(() => {})
afterAll(() => {})
beforeEach(() => {})
afterEach(() => {})
expect(response.status).toBe(403);
expect(await some_parser.parseString("")).toMatchObject({ key: value });
describe('suite', () => {
it(`test case`, async () => {
server = require('../../lib/index').server;
const request = supertest(server);
const response = await request.get('/test/1');
// check using expect
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment