Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Maximilian Michal
grady
Commits
688a77d1
Commit
688a77d1
authored
6 years ago
by
Dominik Seeger
Committed by
robinwilliam.hundt
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added tests for AutoLogout component
parent
f15d6b21
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!128
Merge improve testing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/tests/unit/components/AutoLogout.spec.ts
+13
-3
13 additions, 3 deletions
frontend/tests/unit/components/AutoLogout.spec.ts
with
13 additions
and
3 deletions
frontend/tests/unit/components/AutoLogout.spec.ts
+
13
−
3
View file @
688a77d1
...
@@ -3,6 +3,8 @@ import { mount, createLocalVue } from '@vue/test-utils'
...
@@ -3,6 +3,8 @@ import { mount, createLocalVue } from '@vue/test-utils'
import
AutoLogout
from
'
@/components/AutoLogout.vue
'
import
AutoLogout
from
'
@/components/AutoLogout.vue
'
import
sinon
from
'
sinon
'
import
sinon
from
'
sinon
'
import
{
Authentication
}
from
'
@/store/modules/authentication
'
import
{
Authentication
}
from
'
@/store/modules/authentication
'
import
{
SET_LAST_INTERACTION
}
from
'
@/store/mutations
'
import
{
lastInteraction
}
from
'
@/store/plugins/lastInteractionPlugin
'
import
chai
from
'
chai
'
import
chai
from
'
chai
'
chai
.
should
()
chai
.
should
()
...
@@ -28,7 +30,7 @@ describe('Auto Logout Unit Tests', () => {
...
@@ -28,7 +30,7 @@ describe('Auto Logout Unit Tests', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
=
new
Vuex
.
Store
({
store
=
new
Vuex
.
Store
({
state
:
{}
plugins
:
[
lastInteraction
]
})
})
})
})
...
@@ -43,7 +45,7 @@ describe('Auto Logout Unit Tests', () => {
...
@@ -43,7 +45,7 @@ describe('Auto Logout Unit Tests', () => {
})
})
it
(
'
should be visible when logoutDialog is set to true
'
,
()
=>
{
it
(
'
should be visible when logoutDialog is set to true
'
,
()
=>
{
let
store
=
new
Vuex
.
Store
({})
let
store
=
new
Vuex
.
Store
({})
let
wrapper
=
mount
(
AutoLogout
,
{
localVue
,
store
})
let
wrapper
=
mount
(
AutoLogout
,
{
localVue
:
localVue
,
store
})
wrapper
.
vm
.
$data
.
logoutDialog
=
true
wrapper
.
vm
.
$data
.
logoutDialog
=
true
wrapper
.
html
().
should
.
contain
(
'
<div class="v-dialog v-dialog--active v-dialog--persistent" style="max-width: 30%;">
'
)
wrapper
.
html
().
should
.
contain
(
'
<div class="v-dialog v-dialog--active v-dialog--persistent" style="max-width: 30%;">
'
)
})
})
...
@@ -51,8 +53,16 @@ describe('Auto Logout Unit Tests', () => {
...
@@ -51,8 +53,16 @@ describe('Auto Logout Unit Tests', () => {
let
spy
=
sinon
.
spy
()
let
spy
=
sinon
.
spy
()
sinon
.
replace
(
Authentication
,
'
refreshJWT
'
,
spy
)
sinon
.
replace
(
Authentication
,
'
refreshJWT
'
,
spy
)
let
store
=
new
Vuex
.
Store
({})
let
store
=
new
Vuex
.
Store
({})
let
wrapper
=
mount
(
AutoLogout
,
{
localVue
,
store
})
let
wrapper
=
mount
(
AutoLogout
,
{
localVue
:
localVue
,
store
})
wrapper
.
find
(
'
#continue-btn
'
).
trigger
(
'
click
'
)
wrapper
.
find
(
'
#continue-btn
'
).
trigger
(
'
click
'
)
spy
.
called
.
should
.
equal
(
true
)
spy
.
called
.
should
.
equal
(
true
)
})
})
it
(
'
should automatically update jwt when it is older than 20% of its lifetime
'
,
()
=>
{
// replace lastTokenRefreshTry and jwtTimeDelta from the store to emulate wanted behaviour
let
wrapper
=
mount
(
AutoLogout
,
{
localVue
:
localVue
,
store
})
let
spy
=
sinon
.
spy
()
sinon
.
replaceGetter
(
Authentication
.
state
,
'
jwtTimeDelta
'
,
()
=>
10
*
1
e3
)
sinon
.
replaceGetter
(
Authentication
.
state
,
'
lastTokenRefreshTry
'
,
()
=>
Date
.
now
()
-
2.1
*
1
e3
)
sinon
.
replace
(
Authentication
,
'
refreshJWT
'
,
spy
)
})
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment