Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshuit914 committed Aug 10, 2022
1 parent 1e3eb88 commit 4b85d79
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/config/auth.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const authConfig = require('../../../app/config/auth')

describe('cache Config Test', () => {
const OLD_ENV = process.env

beforeEach(() => {
jest.resetModules()
process.env = { ...OLD_ENV }
})

afterAll(() => {
process.env = OLD_ENV
})
test('Should pass validation for all fields populated', async () => {
expect(authConfig).toBeDefined()
})

test('Invalid env var throws error', () => {
try {
process.env.AADAR_CLIENT_SECRET = null
process.env.AADAR_CLIENT_ID = null
require('../../../app/config/auth')
} catch (err) {
expect(err.message).toBe('The auth config is invalid. "clientSecret" must be a string. "clientId" must be a string')
}
})
})

0 comments on commit 4b85d79

Please sign in to comment.