Skip to content
Snippets Groups Projects
Commit 332b0c65 authored by Xiao Gui's avatar Xiao Gui
Browse files

fix: backend tests

parent ead0adda
No related branches found
No related tags found
No related merge requests found
......@@ -25,13 +25,6 @@ describe('authentication', () => {
const authConfigureAuthStub = sinon.stub(auth, 'configureAuth')
const authIsReadyStub = sinon.stub(auth, 'ready')
require.cache[require.resolve('./datasets')] = {
exports: {
router: (req, res, next) => next(),
ready: async () => true
}
}
require.cache[require.resolve('./saneUrl')] = {
exports: {
router: (req, res, next) => next(),
......@@ -61,7 +54,6 @@ describe('authentication', () => {
})
after(() => {
delete require.cache[require.resolve('./datasets')]
delete require.cache[require.resolve('./saneUrl')]
delete require.cache[require.resolve('./user')]
delete require.cache[require.resolve('./constants')]
......
const sinon = require('sinon')
const { assert, expect } = require('chai')
const initPassportJsStub = sinon.stub()
const hbpOidcStub = sinon.stub()
const hbpOidcV2Stub = sinon.stub()
const appGetStub = sinon.stub()
......@@ -12,9 +10,6 @@ describe('auth/index.js', () => {
require.cache[require.resolve('./util')] = {
exports: { initPassportJs: initPassportJsStub }
}
require.cache[require.resolve('./hbp-oidc')] = {
exports: hbpOidcStub
}
require.cache[require.resolve('./hbp-oidc-v2')] = {
exports: {
bootstrapApp: hbpOidcV2Stub
......@@ -24,9 +19,7 @@ describe('auth/index.js', () => {
beforeEach(() => {
delete require.cache[require.resolve('./index.js')]
hbpOidcStub.returns({})
hbpOidcV2Stub.returns({})
hbpOidcStub.resetHistory()
hbpOidcV2Stub.resetHistory()
})
......@@ -37,11 +30,6 @@ describe('auth/index.js', () => {
const dummyObj = { get: appGetStub }
await configureAuth(dummyObj)
assert(
hbpOidcStub.called,
'hbpOidc called'
)
assert(
hbpOidcV2Stub.called,
'hbpOidcV2 called'
......@@ -58,7 +46,7 @@ describe('auth/index.js', () => {
const { configureAuth } = require('./index.js')
const dummyObj = { get: appGetStub }
hbpOidcStub.throws(`throw error`)
hbpOidcV2Stub.throws(`throw error`)
try {
......@@ -76,14 +64,10 @@ describe('auth/index.js', () => {
} catch (e) {
assert(
hbpOidcStub.calledThrice,
'hbpOidc called thrice'
hbpOidcV2Stub.calledThrice,
'hbpOidcv2 called thrice'
)
assert(
!hbpOidcV2Stub.called,
'hbpOidcV2 not called'
)
}
})
})
......@@ -105,7 +89,7 @@ describe('auth/index.js', () => {
const { configureAuth, ready } = require('./index.js')
const dummyObj = { get: appGetStub }
hbpOidcStub.throws(`throw error`)
hbpOidcV2Stub.throws(`throw error`)
try {
await (() => new Promise((rs, rj) => {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment