Skip to content

Commit

Permalink
test: added test cases for setup strategy #119
Browse files Browse the repository at this point in the history
  • Loading branch information
kdhttps committed Sep 28, 2020
1 parent 3c4f725 commit c428459
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/providers.test.js
@@ -0,0 +1,46 @@
const chai = require('chai')
const rewire = require('rewire')
const providers = rewire('../server/providers.js')
const testConfig = require('../config/test')

const assert = chai.assert

describe('providers setupStrategy', () => {
const passportStrategies = providers.__get__('passportStrategies')

it('passport strategies array should be empty first time', () => {
assert.deepEqual(passportStrategies, [])
})

it('new strategy should be added in passport strategies', () => {
const setupStrategy = providers.__get__('setupStrategy')
const testProvider = {
...testConfig.passportConfigAuthorizedResponse.providers[0],
verifyCallbackArity: 0
}

setupStrategy(testProvider)

assert.lengthOf(passportStrategies, 1)
assert.isFunction(
passportStrategies[0].Strategy,
'Strategy is not a function!'
)
})

it('existing loaded strategy should be found and load again', () => {
const setupStrategy = providers.__get__('setupStrategy')
const testProvider = {
...testConfig.passportConfigAuthorizedResponse.providers[0],
verifyCallbackArity: 0
}

setupStrategy(testProvider)

assert.lengthOf(passportStrategies, 1)
assert.isFunction(
passportStrategies[0].Strategy,
'Strategy is not a function!'
)
})
})

0 comments on commit c428459

Please sign in to comment.