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
6bbba701
Commit
6bbba701
authored
Aug 27, 2019
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Karma spec to Jest for mr_widget_auto_merge_failed
parent
27c222d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
changelogs/unreleased/ce-xanf-move-auto-merge-failed-to-jest.yml
...ogs/unreleased/ce-xanf-move-auto-merge-failed-to-jest.yml
+5
-0
spec/frontend/vue_mr_widget/components/states/mr_widget_auto_merge_failed_spec.js
...get/components/states/mr_widget_auto_merge_failed_spec.js
+55
-0
No files found.
changelogs/unreleased/ce-xanf-move-auto-merge-failed-to-jest.yml
0 → 100644
View file @
6bbba701
---
title
:
Refactored Karma spec to Jest for mr_widget_auto_merge_failed
merge_request
:
32282
author
:
Illya Klymov
type
:
other
spec/
javascripts
/vue_mr_widget/components/states/mr_widget_auto_merge_failed_spec.js
→
spec/
frontend
/vue_mr_widget/components/states/mr_widget_auto_merge_failed_spec.js
View file @
6bbba701
import
Vue
from
'
vue
'
;
import
autoMergeFailedComponent
from
'
~/vue_merge_request_widget/components/states/mr_widget_auto_merge_failed.vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
AutoMergeFailedComponent
from
'
~/vue_merge_request_widget/components/states/mr_widget_auto_merge_failed.vue
'
;
import
eventHub
from
'
~/vue_merge_request_widget/event_hub
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
MRWidgetAutoMergeFailed
'
,
()
=>
{
let
vm
;
let
wrapper
;
const
mergeError
=
'
This is the merge error
'
;
const
findButton
=
()
=>
wrapper
.
find
(
'
button
'
);
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
AutoMergeFailedComponent
,
{
sync
:
false
,
propsData
:
{
...
props
},
});
};
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
autoMergeFailedComponent
);
vm
=
mountComponent
(
Component
,
{
createComponent
({
mr
:
{
mergeError
},
});
});
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
it
(
'
renders failed message
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
This merge request failed to be merged automatically
'
);
expect
(
wrapper
.
text
()
).
toContain
(
'
This merge request failed to be merged automatically
'
);
});
it
(
'
renders merge error provided
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toContain
(
mergeError
);
expect
(
wrapper
.
text
()
).
toContain
(
mergeError
);
});
it
(
'
render refresh button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
button
'
).
textContent
.
trim
()).
toEqual
(
'
Refresh
'
);
expect
(
findButton
().
text
()).
toEqual
(
'
Refresh
'
);
});
it
(
'
emits event and shows loading icon when button is clicked
'
,
done
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
vm
.
$el
.
querySelector
(
'
button
'
).
click
(
);
it
(
'
emits event and shows loading icon when button is clicked
'
,
()
=>
{
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
findButton
().
trigger
(
'
click
'
);
expect
(
eventHub
.
$emit
.
calls
.
argsFor
(
0
)[
0
]).
toEqual
(
'
MRWidgetUpdateRequested
'
);
expect
(
eventHub
.
$emit
.
mock
.
calls
[
0
][
0
]).
toBe
(
'
MRWidgetUpdateRequested
'
);
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
button
'
).
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
expect
(
vm
.
$el
.
querySelector
(
'
button .loading-container span
'
).
classList
).
toContain
(
'
gl-spinner
'
,
);
done
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
findButton
().
attributes
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
expect
(
findButton
()
.
find
(
GlLoadingIcon
)
.
exists
(),
).
toBe
(
true
);
});
});
});
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