Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 0aa9b91

Browse files
committed
add mock request/response with jest and sinon
1 parent 38c5d1d commit 0aa9b91

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

express-handlers.jest-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1+
const mockRequest = (sessionData) => ({
2+
session: { data: sessionData }
3+
});
4+
5+
const mockResponse = () => {
6+
const res = {};
7+
res.status = jest.fn().mockReturnValue(res);
8+
res.json = jest.fn().mockReturnValue(res);
9+
return res;
10+
};
11+
112
test.todo('should pass')

express-handlers.sinon-test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1-
const test = require('ava')
1+
const test = require('ava');
2+
const sinon = require('sinon');
3+
4+
const mockRequest = (sessionData) => ({
5+
session: { data: sessionData }
6+
});
7+
8+
const mockResponse = () => {
9+
const res = {};
10+
res.status = sinon.stub().returns(res);
11+
res.json = sinon.stub().returns(res);
12+
return res;
13+
};
214

315
test.todo('should succeed')

0 commit comments

Comments
 (0)