Skip to content

Commit 214df19

Browse files
fix(cloudrun): correct linting issues in unit tests
1 parent d7df2f2 commit 214df19

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

run/service-auth/test/receive.test.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,60 @@
1414

1515
'use strict';
1616

17-
const { expect } = require('chai');
17+
const {expect} = require('chai');
1818
const sinon = require('sinon');
19-
const { OAuth2Client } = require('google-auth-library');
20-
const { main } = require('../receive');
19+
const {OAuth2Client} = require('google-auth-library');
20+
const {main} = require('../receive');
2121

2222
const TEST_VALID_TOKEN = 'test-valid-token';
2323
const TEST_INVALID_TOKEN = 'test-invalid-token';
2424

2525
describe('receiveRequestAndParseAuthHeader sample', () => {
26-
let verifyStub, consoleStub;
26+
let verifyStub, consoleStub;
2727

28-
beforeEach(() => {
29-
verifyStub = sinon.stub(OAuth2Client.prototype, 'verifyIdToken');
30-
consoleStub = sinon.stub(console, 'log');
31-
});
32-
33-
afterEach(() => {
34-
sinon.restore();
35-
});
28+
beforeEach(() => {
29+
verifyStub = sinon.stub(OAuth2Client.prototype, 'verifyIdToken');
30+
consoleStub = sinon.stub(console, 'log');
31+
});
3632

37-
it('should log greeting if token is valid', async () => {
38-
const mockReq = {
39-
headers: {
40-
authorization: `Bearer ${TEST_VALID_TOKEN}`,
41-
},
42-
};
33+
afterEach(() => {
34+
sinon.restore();
35+
});
4336

44-
verifyStub.resolves({
45-
getPayload: () => ({ email: 'test@example.com' }),
46-
});
37+
it('should log greeting if token is valid', async () => {
38+
const mockReq = {
39+
headers: {
40+
authorization: `Bearer ${TEST_VALID_TOKEN}`,
41+
},
42+
};
4743

48-
await main(mockReq);
49-
expect(consoleStub.calledWith('Hello, test@example.com!\n')).to.be.true;
44+
verifyStub.resolves({
45+
getPayload: () => ({email: 'test@example.com'}),
5046
});
5147

52-
it('should log error message if token is invalid', async () => {
53-
const mockReq = {
54-
headers: {
55-
authorization: `Bearer ${TEST_INVALID_TOKEN}`,
56-
},
57-
};
48+
await main(mockReq);
49+
expect(consoleStub.calledWith('Hello, test@example.com!\n')).to.be.true;
50+
});
5851

59-
verifyStub.rejects(new Error('invalid'));
52+
it('should log error message if token is invalid', async () => {
53+
const mockReq = {
54+
headers: {
55+
authorization: `Bearer ${TEST_INVALID_TOKEN}`,
56+
},
57+
};
6058

61-
await main(mockReq);
62-
expect(consoleStub.calledWithMatch(/Invalid token: invalid/)).to.be.true;
63-
});
59+
verifyStub.rejects(new Error('invalid'));
6460

65-
it('should log anonymous message if no auth header', async () => {
66-
const mockReq = {
67-
headers: {},
68-
};
61+
await main(mockReq);
62+
expect(consoleStub.calledWithMatch(/Invalid token: invalid/)).to.be.true;
63+
});
6964

70-
await main(mockReq);
71-
expect(consoleStub.calledWith('Hello, anonymous user.\n')).to.be.true;
72-
});
65+
it('should log anonymous message if no auth header', async () => {
66+
const mockReq = {
67+
headers: {},
68+
};
69+
70+
await main(mockReq);
71+
expect(consoleStub.calledWith('Hello, anonymous user.\n')).to.be.true;
72+
});
7373
});

0 commit comments

Comments
 (0)