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
6f6883d0
Commit
6f6883d0
authored
6 years ago
by
Dominik Seeger
Committed by
robinwilliam.hundt
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
changed to use testUtils / added a test
parent
06ccdacc
No related branches found
No related tags found
1 merge request
!128
Merge improve testing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/tests/unit/components/DataExport.spec.ts
+18
-18
18 additions, 18 deletions
frontend/tests/unit/components/DataExport.spec.ts
with
18 additions
and
18 deletions
frontend/tests/unit/components/DataExport.spec.ts
+
18
−
18
View file @
6f6883d0
...
...
@@ -4,6 +4,7 @@ import DataExport from '@/components/export/DataExport.vue'
import
sinon
from
'
sinon
'
import
chai
from
'
chai
'
import
VueRouter
from
'
vue-router
'
import
testUtils
from
'
@/../tests/utils/testUtils
'
import
*
as
api
from
'
@/api
'
chai
.
should
()
...
...
@@ -23,17 +24,6 @@ describe('DataExport Component Unit Tests', () => {
error
:
console
.
error
}
// for creating test data
let
students
=
[{
Matrikel
:
1000000
,
Name
:
'
test
'
,
Username
:
'
test
'
,
Sum
:
100
,
Exam
:
'
test
'
,
Password
:
'
test
'
,
Scores
:
{
type
:
'
test
'
,
score
:
100
}
}]
before
(
function
()
{
console
.
warn
=
function
()
{}
console
.
error
=
function
()
{}
...
...
@@ -63,7 +53,7 @@ describe('DataExport Component Unit Tests', () => {
// @ts-ignore
sinon
.
replace
(
wrapper
.
vm
,
'
createDownloadPopup
'
,
sinon
.
spy
())
// @ts-ignore
wrapper
.
vm
.
optionalConvertAndCreatePopup
(
studen
ts
)
wrapper
.
vm
.
optionalConvertAndCreatePopup
(
testUtils
.
studentExpor
ts
)
spy
.
called
.
should
.
equal
(
true
)
})
it
(
'
should download JSON when selected
'
,
()
=>
{
...
...
@@ -75,12 +65,12 @@ describe('DataExport Component Unit Tests', () => {
// @ts-ignore
sinon
.
replace
(
wrapper
.
vm
,
'
createDownloadPopup
'
,
sinon
.
spy
())
// @ts-ignore
wrapper
.
vm
.
optionalConvertAndCreatePopup
(
studen
ts
)
wrapper
.
vm
.
optionalConvertAndCreatePopup
(
testUtils
.
studentExpor
ts
)
spy
.
called
.
should
.
equal
(
false
)
})
it
(
'
should download obfuscated data when no mapping was selected
'
,
async
()
=>
{
let
wrapper
=
mount
(
DataExport
,
{
localVue
:
localVue
,
store
})
let
stub
=
sinon
.
stub
().
returns
(
Promise
.
resolve
({
data
:
studen
ts
}))
let
stub
=
sinon
.
stub
().
returns
(
Promise
.
resolve
({
data
:
testUtils
.
studentExpor
ts
}))
let
spy
=
sinon
.
spy
()
// @ts-ignore replace ax.post because of fetch in getExportFile
sinon
.
replace
(
api
.
default
,
'
post
'
,
stub
)
...
...
@@ -88,10 +78,20 @@ describe('DataExport Component Unit Tests', () => {
sinon
.
replace
(
wrapper
.
vm
,
'
optionalConvertAndCreatePopup
'
,
spy
)
// @ts-ignore
await
wrapper
.
vm
.
getExportFile
(
'
data
'
)
spy
.
called
.
should
.
equal
(
true
)
spy
.
calledWithExactly
(
students
).
should
.
equal
(
true
)
spy
.
calledWithExactly
(
testUtils
.
studentExports
).
should
.
equal
(
true
)
})
it
(
'
should download deobfuscated data when no mapping was selected
'
,
async
()
=>
{
it
(
'
should download deobfuscated data when mapping was selected
'
,
async
()
=>
{
let
wrapper
=
mount
(
DataExport
,
{
localVue
:
localVue
,
store
})
let
stub
=
sinon
.
stub
().
returns
(
Promise
.
resolve
({
data
:
testUtils
.
studentExports
}))
let
spy
=
sinon
.
spy
()
// @ts-ignore
wrapper
.
vm
.
mapFile
=
testUtils
.
fakeFile
// @ts-ignore replace ax.post because of fetch in getExportFile
sinon
.
replace
(
api
.
default
,
'
post
'
,
stub
)
// @ts-ignore
sinon
.
replace
(
wrapper
.
vm
,
'
getMappedExportFile
'
,
spy
)
// @ts-ignore
await
wrapper
.
vm
.
getExportFile
(
'
data
'
)
spy
.
calledWithExactly
(
testUtils
.
studentExports
).
should
.
equal
(
true
)
})
})
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