Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions test/unit/ci_start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Jenkins', () => {
});
});

it('should fail if starting node-pull-request throws', async() => {
it('should fail if starting node-pull-request throws', async(t) => {
const cli = new TestCLI();
const request = {
fetch: sinon.stub().returns(Promise.resolve({ status: 400 })),
Expand All @@ -53,20 +53,20 @@ describe('Jenkins', () => {
};

const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true);
assert.strictEqual(await jobRunner.start(), false);
(t.assert ?? assert).strictEqual(await jobRunner.start(), false);
});

it('should return false if crumb fails', async() => {
it('should return false if crumb fails', async(t) => {
const cli = new TestCLI();
const request = {
json: sinon.stub().throws()
};

const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true);
assert.strictEqual(await jobRunner.start(), false);
(t.assert ?? assert).strictEqual(await jobRunner.start(), false);
});

it('should start node-pull-request', async() => {
it('should start node-pull-request', async(t) => {
const cli = new TestCLI();

const request = {
Expand All @@ -81,36 +81,36 @@ describe('Jenkins', () => {
}),
fetch: sinon.stub()
.callsFake((url, { method, headers, body }) => {
assert.strictEqual(url, CI_PR_URL);
assert.strictEqual(method, 'POST');
assert.deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
assert.ok(body._validated);
(t.assert ?? assert).strictEqual(url, CI_PR_URL);
(t.assert ?? assert).strictEqual(method, 'POST');
(t.assert ?? assert).deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
(t.assert ?? assert).ok(body._validated);
return Promise.resolve({ status: 201 });
}),
json: sinon.stub().withArgs(CI_CRUMB_URL)
.returns(Promise.resolve({ crumb }))
};
const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true);
assert.ok(await jobRunner.start());
(t.assert ?? assert).ok(await jobRunner.start());
});

it('should return false if node-pull-request not started', async() => {
it('should return false if node-pull-request not started', async(t) => {
const cli = new TestCLI();

const request = {
fetch: sinon.stub()
.callsFake((url, { method, headers, body }) => {
assert.strictEqual(url, CI_PR_URL);
assert.strictEqual(method, 'POST');
assert.deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
assert.ok(body._validated);
(t.assert ?? assert).strictEqual(url, CI_PR_URL);
(t.assert ?? assert).strictEqual(method, 'POST');
(t.assert ?? assert).deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
(t.assert ?? assert).ok(body._validated);
return Promise.resolve({ status: 401 });
}),
json: sinon.stub().withArgs(CI_CRUMB_URL)
.returns(Promise.resolve({ crumb }))
};
const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true);
assert.strictEqual(await jobRunner.start(), false);
(t.assert ?? assert).strictEqual(await jobRunner.start(), false);
});

describe('without --certify-safe flag', { concurrency: false }, () => {
Expand All @@ -120,7 +120,7 @@ describe('Jenkins', () => {
for (const certifySafe of [true, false]) {
it(`should return ${certifySafe} if PR checker reports it as ${
certifySafe ? '' : 'potentially un'
}safe`, async() => {
}safe`, async(t) => {
const cli = new TestCLI();

sinon.replace(PRChecker.prototype, 'checkCommitsAfterReview',
Expand All @@ -138,18 +138,18 @@ describe('Jenkins', () => {
}),
fetch: sinon.stub()
.callsFake((url, { method, headers, body }) => {
assert.strictEqual(url, CI_PR_URL);
assert.strictEqual(method, 'POST');
assert.deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
assert.ok(body._validated);
(t.assert ?? assert).strictEqual(url, CI_PR_URL);
(t.assert ?? assert).strictEqual(method, 'POST');
(t.assert ?? assert).deepStrictEqual(headers, { 'Jenkins-Crumb': crumb });
(t.assert ?? assert).ok(body._validated);
return Promise.resolve({ status: 201 });
}),
json: sinon.stub().withArgs(CI_CRUMB_URL)
.returns(Promise.resolve({ crumb }))
};

const jobRunner = new RunPRJob(cli, request, owner, repo, prid, false);
assert.strictEqual(await jobRunner.start(), certifySafe);
(t.assert ?? assert).strictEqual(await jobRunner.start(), certifySafe);
});
}
});
Expand Down
Loading