-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathintegration.ts
More file actions
34 lines (30 loc) · 787 Bytes
/
integration.ts
File metadata and controls
34 lines (30 loc) · 787 Bytes
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
27
28
29
30
31
32
33
34
'use strict';
import { start, InvokerOptions } from 'faas-js-runtime';
import request from 'supertest';
import * as func from '../build';
import test, { Test } from 'tape';
const data = {
name: 'tiger',
customerId: '01234'
};
const errHandler = (t: Test) => (err: Error) => {
t.error(err);
t.end();
};
test('Integration: handles a valid request', (t) => {
start(func.handle, {} as InvokerOptions).then((server) => {
t.plan(3);
request(server)
.post('/')
.send(data)
.expect(200)
.expect('Content-Type', /json/)
.end((err, result) => {
t.error(err, 'No error');
t.ok(result);
t.equal(JSON.stringify(result.body), JSON.stringify(data));
t.end();
server.close();
});
}, errHandler(t));
});