2017-05-20 20:55:37 +00:00
|
|
|
|
|
|
|
import sinon = require("sinon");
|
2017-05-21 10:27:12 +00:00
|
|
|
import express = require("express");
|
2017-05-20 20:55:37 +00:00
|
|
|
|
2017-05-20 23:15:34 +00:00
|
|
|
export interface RequestMock {
|
|
|
|
app?: any;
|
|
|
|
body?: any;
|
|
|
|
session?: any;
|
|
|
|
headers?: any;
|
2017-05-21 10:27:12 +00:00
|
|
|
get?: any;
|
2017-05-20 23:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseMock {
|
|
|
|
send: sinon.SinonStub | sinon.SinonSpy;
|
2017-05-21 10:27:12 +00:00
|
|
|
sendStatus: sinon.SinonStub;
|
|
|
|
sendFile: sinon.SinonStub;
|
|
|
|
sendfile: sinon.SinonStub;
|
2017-05-21 11:11:54 +00:00
|
|
|
status: sinon.SinonStub | sinon.SinonSpy;
|
2017-05-20 23:15:34 +00:00
|
|
|
json: sinon.SinonStub;
|
2017-05-21 10:27:12 +00:00
|
|
|
links: sinon.SinonStub;
|
|
|
|
jsonp: sinon.SinonStub;
|
|
|
|
download: sinon.SinonStub;
|
|
|
|
contentType: sinon.SinonStub;
|
|
|
|
type: sinon.SinonStub;
|
|
|
|
format: sinon.SinonStub;
|
|
|
|
attachment: sinon.SinonStub;
|
|
|
|
set: sinon.SinonStub;
|
|
|
|
header: sinon.SinonStub;
|
|
|
|
headersSent: boolean;
|
|
|
|
get: sinon.SinonStub;
|
|
|
|
clearCookie: sinon.SinonStub;
|
|
|
|
cookie: sinon.SinonStub;
|
|
|
|
location: sinon.SinonStub;
|
|
|
|
redirect: sinon.SinonStub;
|
|
|
|
render: sinon.SinonStub;
|
|
|
|
locals: sinon.SinonStub;
|
|
|
|
charset: string;
|
|
|
|
vary: sinon.SinonStub;
|
|
|
|
app: any;
|
|
|
|
write: sinon.SinonStub;
|
|
|
|
writeContinue: sinon.SinonStub;
|
|
|
|
writeHead: sinon.SinonStub;
|
|
|
|
statusCode: number;
|
|
|
|
statusMessage: string;
|
|
|
|
setHeader: sinon.SinonStub;
|
|
|
|
setTimeout: sinon.SinonStub;
|
|
|
|
sendDate: boolean;
|
|
|
|
getHeader: sinon.SinonStub;
|
2017-05-20 23:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function RequestMock(): RequestMock {
|
|
|
|
return {
|
|
|
|
app: {
|
|
|
|
get: sinon.stub()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export function ResponseMock(): ResponseMock {
|
|
|
|
return {
|
|
|
|
send: sinon.stub(),
|
|
|
|
status: sinon.stub(),
|
2017-05-21 10:27:12 +00:00
|
|
|
json: sinon.stub(),
|
|
|
|
sendStatus: sinon.stub(),
|
|
|
|
links: sinon.stub(),
|
|
|
|
jsonp: sinon.stub(),
|
|
|
|
sendFile: sinon.stub(),
|
|
|
|
sendfile: sinon.stub(),
|
|
|
|
download: sinon.stub(),
|
|
|
|
contentType: sinon.stub(),
|
|
|
|
type: sinon.stub(),
|
|
|
|
format: sinon.stub(),
|
|
|
|
attachment: sinon.stub(),
|
|
|
|
set: sinon.stub(),
|
|
|
|
header: sinon.stub(),
|
|
|
|
headersSent: true,
|
|
|
|
get: sinon.stub(),
|
|
|
|
clearCookie: sinon.stub(),
|
|
|
|
cookie: sinon.stub(),
|
|
|
|
location: sinon.stub(),
|
|
|
|
redirect: sinon.stub(),
|
|
|
|
render: sinon.stub(),
|
|
|
|
locals: sinon.stub(),
|
|
|
|
charset: "utf-8",
|
|
|
|
vary: sinon.stub(),
|
|
|
|
app: sinon.stub(),
|
|
|
|
write: sinon.stub(),
|
|
|
|
writeContinue: sinon.stub(),
|
|
|
|
writeHead: sinon.stub(),
|
|
|
|
statusCode: 200,
|
|
|
|
statusMessage: "message",
|
|
|
|
setHeader: sinon.stub(),
|
|
|
|
setTimeout: sinon.stub(),
|
|
|
|
sendDate: true,
|
|
|
|
getHeader: sinon.stub()
|
2017-05-20 23:15:34 +00:00
|
|
|
};
|
|
|
|
}
|