Skip to content

Commit

Permalink
Clone the events object when running render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-steele-idem committed Oct 11, 2017
1 parent 83f711d commit 5f686b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"browser-refresh-taglib": "^1.1.0",
"chai": "^3.3.0",
"child-process-promise": "^2.2.1",
"clone": "^2.1.1",
"codecov": "^2.3.0",
"coveralls": "^2.13.1",
"express": "^4.16.1",
Expand Down
21 changes: 16 additions & 5 deletions test/util/runRenderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const domToHTML = require('./domToHTML');
const domToString = require('./domToString');

const expect = require('chai').expect;

const clone = require('clone');


function createAsyncVerifier(main, helpers, out) {
Expand All @@ -29,7 +29,7 @@ function createAsyncVerifier(main, helpers, out) {

events.push({
event: event,
arg: arg
arg: clone(arg)
});
});
};
Expand Down Expand Up @@ -149,8 +149,7 @@ module.exports = function runRenderTest(dir, helpers, done, options) {
asyncEventsVerifier = createAsyncVerifier(main, helpers, out);
}

out.on('error', done);
out.on('finish', function(result) {
function verifyOutput(result) {
var renderOutput = result.getOutput();

if (isVDOM) {
Expand Down Expand Up @@ -235,7 +234,19 @@ module.exports = function runRenderTest(dir, helpers, done, options) {

done();
}
});
}

out.then(
function onFulfilled(result) {
process.nextTick(function() {
verifyOutput(result);
});
},
function onRejected(err) {
process.nextTick(function() {
done(err);
});
});

template.render(templateData, out).end();
}
Expand Down

0 comments on commit 5f686b8

Please sign in to comment.