Skip to content

Commit

Permalink
chore: upgrade deps
Browse files Browse the repository at this point in the history
changelog
fix unit test
update jest config

OKTA-406686
<<<Jenkins Check-In of Tested SHA: 899d824 for [email protected]>>>
Artifact: okta-vue
Files changed count: 4
PR Link: "#68"
  • Loading branch information
shuowu authored and eng-prod-CI-bot-okta committed Jun 23, 2021
1 parent a3599f6 commit a2319d9
Show file tree
Hide file tree
Showing 4 changed files with 2,233 additions and 2,045 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- Removed `isPending` from `AuthState`
- Default value for `originalUri` is null

### Others

- [#68](https://github.com/okta/okta-vue/pull/68) Upgrades dependencies

# 4.0.1

### Bug Fixes
Expand Down
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,5 @@ module.exports = {
'^.+\\.jsx?$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
moduleNameMapper: {
'^@okta/okta-auth-js$': '<rootDir>/node_modules/@okta/okta-auth-js/dist/okta-auth-js.umd.js'
},
testEnvironment: 'jsdom'
}
20 changes: 8 additions & 12 deletions test/specs/LoginCallback.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@ describe('LoginCallback', () => {

async function navigateToCallback (options = {}) {
jest.spyOn(oktaAuth, 'isLoginRedirect').mockReturnValue(options.isLoginRedirect)
jest.spyOn(oktaAuth, 'storeTokensFromRedirect').mockImplementation(() => {
return new Promise(resolve => {
if (oktaAuth.isLoginRedirect()) {
oktaAuth.emitter.emit('authStateChange', { })
}
resolve()
})
})
oktaAuth.options.restoreOriginalUri = jest.fn()
jest.spyOn(oktaAuth, 'storeTokensFromRedirect').mockResolvedValue(undefined)
const router = createRouter({
history: createWebHistory(),
routes: [
Expand All @@ -60,17 +52,15 @@ describe('LoginCallback', () => {
]
}
})

router.push('/')
await router.isReady()
await nextTick() // let promise from handleLoginRedirect resolve
}

it('renders the component', async () => {
createOktaAuth()
jest.spyOn(LoginCallback, 'render')
await navigateToCallback()
await
expect(LoginCallback.render).toHaveBeenCalled()
expect(wrapper.text()).toBe('')
})
Expand All @@ -85,12 +75,18 @@ describe('LoginCallback', () => {
it('calls the default "restoreOriginalUri" options when in login redirect uri', async () => {
createOktaAuth()
await navigateToCallback({ isLoginRedirect: true })
jest.spyOn(oktaAuth.options, 'restoreOriginalUri')
// nextTick only wait on dom updates, explicitly wait for the next event loop happen as no dom update here
await new Promise(resolve => setTimeout(resolve))
expect(oktaAuth.options.restoreOriginalUri).toHaveBeenCalled()
})

it('should not call the default "restoreOriginalUri" options when not in login redirect uri', async () => {
createOktaAuth()
await navigateToCallback({ isLoginRedirect: false })
jest.spyOn(oktaAuth.options, 'restoreOriginalUri');
// nextTick only wait on dom updates, explicitly wait for the next event loop happen as no dom update here
await new Promise(resolve => setTimeout(resolve))
expect(oktaAuth.options.restoreOriginalUri).not.toHaveBeenCalled()
})

Expand Down
Loading

0 comments on commit a2319d9

Please sign in to comment.