Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c6bc8605
Commit
c6bc8605
authored
Nov 24, 2021
by
Fernando Arias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for mutations
* Mock out moutations but test they are called at the right time
parent
3aee0a8d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
ee/spec/frontend/security_configuration/corpus_management/components/__snapshots__/corpus_upload_form_spec.js.snap
.../components/__snapshots__/corpus_upload_form_spec.js.snap
+3
-1
ee/spec/frontend/security_configuration/corpus_management/components/corpus_upload_spec.js
...ration/corpus_management/components/corpus_upload_spec.js
+43
-1
No files found.
ee/spec/frontend/security_configuration/corpus_management/components/__snapshots__/corpus_upload_form_spec.js.snap
View file @
c6bc8605
...
@@ -28,7 +28,9 @@ exports[`Corpus upload modal corpus modal uploading state does show the upload p
...
@@ -28,7 +28,9 @@ exports[`Corpus upload modal corpus modal uploading state does show the upload p
<span
<span
class="gl-button-text"
class="gl-button-text"
>
>
Cancel
Cancel
</span>
</span>
</button>
</button>
</div>
</div>
...
...
ee/spec/frontend/security_configuration/corpus_management/components/corpus_upload_spec.js
View file @
c6bc8605
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlModal
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
CorpusUpload
from
'
ee/security_configuration/corpus_management/components/corpus_upload.vue
'
;
import
CorpusUpload
from
'
ee/security_configuration/corpus_management/components/corpus_upload.vue
'
;
import
CorpusUploadForm
from
'
ee/security_configuration/corpus_management/components/corpus_upload_form.vue
'
;
const
TEST_PROJECT_FULL_PATH
=
'
/namespace/project
'
;
const
TEST_PROJECT_FULL_PATH
=
'
/namespace/project
'
;
describe
(
'
Corpus Upload
'
,
()
=>
{
describe
(
'
Corpus Upload
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
findModal
=
()
=>
wrapper
.
findComponent
(
GlModal
);
const
findCorpusUploadForm
=
()
=>
wrapper
.
findComponent
(
CorpusUploadForm
);
const
createComponentFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{})
=>
{
const
createComponentFactory
=
(
mountFn
=
shallowMount
)
=>
(
options
=
{})
=>
{
const
defaultProps
=
{
totalSize
:
4
e8
};
const
defaultProps
=
{
totalSize
:
4
e8
};
wrapper
=
mountFn
(
CorpusUpload
,
{
wrapper
=
mountFn
(
CorpusUpload
,
{
...
@@ -37,5 +41,43 @@ describe('Corpus Upload', () => {
...
@@ -37,5 +41,43 @@ describe('Corpus Upload', () => {
expect
(
wrapper
.
findComponent
(
GlButton
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findComponent
(
GlButton
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
describe
(
'
addCorpus mutation
'
,
()
=>
{
it
(
'
called when the add button is clicked from the modal
'
,
async
()
=>
{
createComponent
();
jest
.
spyOn
(
wrapper
.
vm
,
'
addCorpus
'
).
mockImplementation
(()
=>
{});
await
wrapper
.
vm
.
$forceUpdate
();
findModal
().
vm
.
$emit
(
'
primary
'
);
expect
(
wrapper
.
vm
.
addCorpus
).
toHaveBeenCalled
();
});
});
describe
(
'
resetCorpus mutation
'
,
()
=>
{
it
(
'
called when the cancel button is clicked from the modal
'
,
async
()
=>
{
createComponent
();
jest
.
spyOn
(
wrapper
.
vm
,
'
resetCorpus
'
).
mockImplementation
(()
=>
{});
await
wrapper
.
vm
.
$forceUpdate
();
findModal
().
vm
.
$emit
(
'
canceled
'
);
expect
(
wrapper
.
vm
.
resetCorpus
).
toHaveBeenCalled
();
});
it
(
'
called when the upload form triggers a reset
'
,
async
()
=>
{
createComponent
();
jest
.
spyOn
(
wrapper
.
vm
,
'
resetCorpus
'
).
mockImplementation
(()
=>
{});
await
wrapper
.
vm
.
$forceUpdate
();
findCorpusUploadForm
().
vm
.
$emit
(
'
resetCorpus
'
);
expect
(
wrapper
.
vm
.
resetCorpus
).
toHaveBeenCalled
();
});
});
describe
(
'
uploadCorpus mutation
'
,
()
=>
{
it
(
'
called when the upload file is clicked from the modal
'
,
async
()
=>
{
createComponent
();
jest
.
spyOn
(
wrapper
.
vm
,
'
beginFileUpload
'
).
mockImplementation
(()
=>
{});
await
wrapper
.
vm
.
$forceUpdate
();
findCorpusUploadForm
().
vm
.
$emit
(
'
beginFileUpload
'
);
expect
(
wrapper
.
vm
.
beginFileUpload
).
toHaveBeenCalled
();
});
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment