-
Notifications
You must be signed in to change notification settings - Fork 35
/
test-mocks.js
56 lines (41 loc) · 966 Bytes
/
test-mocks.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var _ = require('lodash');
var sinon = require('sinon');
var FakeContext = function() {
this._renderArgs = [];
this.id = 'some-request-id';
this.throw = sinon.spy();
this.request = {
ip: '127.0.0.1',
body: {},
query: {},
method: '',
url: '',
header: {
host: ''
},
headers: {
'x-forwarded-for': ''
}
};
this.validatedData = {};
};
FakeContext.prototype = {
render: function() {
this._renderArgs.push(arguments);
},
getLastRenderArgs: function() {
return _.last(this._renderArgs);
},
getLastRenderData: function() {
return this.getLastRenderArgs()[1];
},
setValidatedData: function(validatedData) {
this.request.validatedData = validatedData;
}
};
FakeContext.create = function() {
return new FakeContext(arguments);
};
module.exports.FakeContext = FakeContext;
module.exports.FakeTranslationRenderDecorator = { decorate: async function() {} };