Skip to content

Commit 733bd44

Browse files
committed
cleaner teardown
1 parent 37696bd commit 733bd44

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/unit/ci_start.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Jenkins', () => {
2323
const dummySHA = '51ce389dc1d539216d30bba0986a8c270801d65f';
2424

2525
before(() => {
26-
sinon.stub(FormData.prototype, 'append').callsFake(function(key, value) {
26+
const stubbed = sinon.stub(FormData.prototype, 'append').callsFake(function(key, value) {
2727
assert.strictEqual(key, 'json');
2828
const { parameter } = JSON.parse(value);
2929
const expectedParameters = {
@@ -45,6 +45,8 @@ describe('Jenkins', () => {
4545

4646
return Reflect.apply(FormData.prototype.append.wrappedMethod, this, arguments);
4747
});
48+
49+
return () => stubbed.restore();
4850
});
4951

5052
it('should fail if starting node-pull-request throws', async() => {
@@ -121,12 +123,17 @@ describe('Jenkins', () => {
121123
before(() => {
122124
sinon.replace(PRData.prototype, 'getReviews', function() {});
123125
sinon.replace(PRData.prototype, 'getCommits', function() {});
126+
return () => {
127+
PRData.prototype.getReviews.restore();
128+
PRData.prototype.getCommits.restore();
129+
};
124130
});
125131
afterEach(() => {
126132
PRData.prototype.getCollaborators.restore();
127133
PRData.prototype.getComments.restore();
128134
PRChecker.prototype.getApprovedTipOfHead.restore();
129135
});
136+
130137
for (const { headIsApproved = false, collaborators = [], comments = [], expected } of [{
131138
headIsApproved: true,
132139
expected: true,

0 commit comments

Comments
 (0)