Skip to content

Commit

Permalink
fix(render): Change render
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Change render to return a promise as the new koa-pug 4.0+ introduced a breaking change
Co-authored-by: Laszlo Hammerl <[email protected]>
  • Loading branch information
sigee committed Sep 15, 2021
1 parent aaee13e commit 13ac33b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions mocks/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var sinon = require('sinon');
let sinon = require('sinon');

var AppMock = function() {
let AppMock = function() {
this.use = sinon.stub();
};

Expand Down
9 changes: 6 additions & 3 deletions mocks/context.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var sinon = require('sinon');
let sinon = require('sinon');


var FakeContext = function() {
let FakeContext = function() {
this._renderArgs = [];
this.status = 200;
this.id = 'some-request-id';
Expand All @@ -28,7 +28,10 @@ var FakeContext = function() {
FakeContext.prototype = {

render: function() {
this._renderArgs.push(arguments);
return new Promise(resolve => {
this._renderArgs.push(arguments);
resolve(this._renderArgs);
});
},


Expand Down
17 changes: 10 additions & 7 deletions mocks/render.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var hooks = require('boar-server').middlewares.hook;
let hooks = require('boar-server').middlewares.hook;

var context;
var renderArguments;
var originalRender;
let context;
let renderArguments;
let originalRender;

module.exports = {

Expand All @@ -21,9 +21,12 @@ module.exports = {
originalRender = this.render;
context = this;
this.render = function(path, data) {
renderArguments = {path: path, data: data};
context.body = "RENDER STUB";
context.type = "html";
return new Promise(resolve => {
renderArguments = {path: path, data: data};
context.body = "RENDER STUB";
context.type = "html";
resolve(context);
});
};
}
});
Expand Down
4 changes: 2 additions & 2 deletions mocks/router.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var sinon = require('sinon');
let sinon = require('sinon');

var RouterMock = function() {
let RouterMock = function() {
this.get = sinon.stub();
this.post = sinon.stub();
this.put = sinon.stub();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"boar-server": "*"
},
"devDependencies": {
"semantic-release": "15.5.0"
"semantic-release": "15.14.0"
}
}

0 comments on commit 13ac33b

Please sign in to comment.