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
36cf5526
Commit
36cf5526
authored
Dec 22, 2020
by
jboyson
Committed by
Denys Mishunov
Jan 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace mount helper with mount from VTU
parent
54b1afcb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
27 deletions
+24
-27
spec/frontend/diffs/components/diff_expansion_cell_spec.js
spec/frontend/diffs/components/diff_expansion_cell_spec.js
+24
-27
No files found.
spec/frontend/diffs/components/diff_expansion_cell_spec.js
View file @
36cf5526
import
Vue
from
'
vue
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
getByText
}
from
'
@testing-library/dom
'
;
import
{
getByText
}
from
'
@testing-library/dom
'
;
import
{
createStore
}
from
'
~/mr_notes/stores
'
;
import
{
createStore
}
from
'
~/mr_notes/stores
'
;
import
DiffExpansionCell
from
'
~/diffs/components/diff_expansion_cell.vue
'
;
import
DiffExpansionCell
from
'
~/diffs/components/diff_expansion_cell.vue
'
;
...
@@ -59,7 +58,6 @@ describe('DiffExpansionCell', () => {
...
@@ -59,7 +58,6 @@ describe('DiffExpansionCell', () => {
let
mockFile
;
let
mockFile
;
let
mockLine
;
let
mockLine
;
let
store
;
let
store
;
let
vm
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mockFile
=
cloneDeep
(
diffFileMockData
);
mockFile
=
cloneDeep
(
diffFileMockData
);
...
@@ -70,7 +68,6 @@ describe('DiffExpansionCell', () => {
...
@@ -70,7 +68,6 @@ describe('DiffExpansionCell', () => {
});
});
const
createComponent
=
(
options
=
{})
=>
{
const
createComponent
=
(
options
=
{})
=>
{
const
cmp
=
Vue
.
extend
(
DiffExpansionCell
);
const
defaults
=
{
const
defaults
=
{
fileHash
:
mockFile
.
file_hash
,
fileHash
:
mockFile
.
file_hash
,
contextLinesPath
:
'
contextLinesPath
'
,
contextLinesPath
:
'
contextLinesPath
'
,
...
@@ -78,46 +75,46 @@ describe('DiffExpansionCell', () => {
...
@@ -78,46 +75,46 @@ describe('DiffExpansionCell', () => {
isTop
:
false
,
isTop
:
false
,
isBottom
:
false
,
isBottom
:
false
,
};
};
const
props
=
{
...
defaults
,
...
options
};
const
props
Data
=
{
...
defaults
,
...
options
};
vm
=
createComponentWithStore
(
cmp
,
store
,
props
).
$mount
(
);
return
mount
(
DiffExpansionCell
,
{
store
,
propsData
}
);
};
};
const
findExpandUp
=
()
=>
vm
.
$el
.
querySelector
(
EXPAND_UP_CLASS
);
const
findExpandUp
=
wrapper
=>
wrapper
.
find
(
EXPAND_UP_CLASS
);
const
findExpandDown
=
()
=>
vm
.
$el
.
querySelector
(
EXPAND_DOWN_CLASS
);
const
findExpandDown
=
wrapper
=>
wrapper
.
find
(
EXPAND_DOWN_CLASS
);
const
findExpandAll
=
(
)
=>
getByText
(
vm
.
$el
,
'
Show all unchanged lines
'
);
const
findExpandAll
=
(
{
element
})
=>
getByText
(
element
,
'
Show all unchanged lines
'
);
describe
(
'
top row
'
,
()
=>
{
describe
(
'
top row
'
,
()
=>
{
it
(
'
should have "expand up" and "show all" option
'
,
()
=>
{
it
(
'
should have "expand up" and "show all" option
'
,
()
=>
{
createComponent
({
c
onst
wrapper
=
c
reateComponent
({
isTop
:
true
,
isTop
:
true
,
});
});
expect
(
findExpandUp
(
)).
not
.
toBe
(
null
);
expect
(
findExpandUp
(
wrapper
).
exists
()).
toBe
(
true
);
expect
(
findExpandDown
(
)).
toBe
(
null
);
expect
(
findExpandDown
(
wrapper
).
exists
()).
toBe
(
false
);
expect
(
findExpandAll
()).
not
.
toBe
(
null
);
expect
(
findExpandAll
(
wrapper
)).
not
.
toBe
(
null
);
});
});
});
});
describe
(
'
middle row
'
,
()
=>
{
describe
(
'
middle row
'
,
()
=>
{
it
(
'
should have "expand down", "show all", "expand up" option
'
,
()
=>
{
it
(
'
should have "expand down", "show all", "expand up" option
'
,
()
=>
{
createComponent
();
c
onst
wrapper
=
c
reateComponent
();
expect
(
findExpandUp
(
)).
not
.
toBe
(
null
);
expect
(
findExpandUp
(
wrapper
).
exists
()).
toBe
(
true
);
expect
(
findExpandDown
(
)).
not
.
toBe
(
null
);
expect
(
findExpandDown
(
wrapper
).
exists
()).
toBe
(
true
);
expect
(
findExpandAll
()).
not
.
toBe
(
null
);
expect
(
findExpandAll
(
wrapper
)).
not
.
toBe
(
null
);
});
});
});
});
describe
(
'
bottom row
'
,
()
=>
{
describe
(
'
bottom row
'
,
()
=>
{
it
(
'
should have "expand down" and "show all" option
'
,
()
=>
{
it
(
'
should have "expand down" and "show all" option
'
,
()
=>
{
createComponent
({
c
onst
wrapper
=
c
reateComponent
({
isBottom
:
true
,
isBottom
:
true
,
});
});
expect
(
findExpandUp
(
)).
toBe
(
null
);
expect
(
findExpandUp
(
wrapper
).
exists
()).
toBe
(
false
);
expect
(
findExpandDown
(
)).
not
.
toBe
(
null
);
expect
(
findExpandDown
(
wrapper
).
exists
()).
toBe
(
true
);
expect
(
findExpandAll
()).
not
.
toBe
(
null
);
expect
(
findExpandAll
(
wrapper
)).
not
.
toBe
(
null
);
});
});
});
});
...
@@ -144,9 +141,9 @@ describe('DiffExpansionCell', () => {
...
@@ -144,9 +141,9 @@ describe('DiffExpansionCell', () => {
newLineNumber
,
newLineNumber
,
});
});
createComponent
();
c
onst
wrapper
=
c
reateComponent
();
findExpandAll
().
click
();
findExpandAll
(
wrapper
).
click
();
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/loadMoreLines
'
,
'
diffs/loadMoreLines
'
,
...
@@ -167,9 +164,9 @@ describe('DiffExpansionCell', () => {
...
@@ -167,9 +164,9 @@ describe('DiffExpansionCell', () => {
const
oldLineNumber
=
mockLine
.
meta_data
.
old_pos
;
const
oldLineNumber
=
mockLine
.
meta_data
.
old_pos
;
const
newLineNumber
=
mockLine
.
meta_data
.
new_pos
;
const
newLineNumber
=
mockLine
.
meta_data
.
new_pos
;
createComponent
();
c
onst
wrapper
=
c
reateComponent
();
findExpandUp
(
).
click
(
);
findExpandUp
(
wrapper
).
trigger
(
'
click
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/loadMoreLines
'
,
'
diffs/loadMoreLines
'
,
...
@@ -195,9 +192,9 @@ describe('DiffExpansionCell', () => {
...
@@ -195,9 +192,9 @@ describe('DiffExpansionCell', () => {
mockLine
.
meta_data
.
old_pos
=
200
;
mockLine
.
meta_data
.
old_pos
=
200
;
mockLine
.
meta_data
.
new_pos
=
200
;
mockLine
.
meta_data
.
new_pos
=
200
;
createComponent
();
c
onst
wrapper
=
c
reateComponent
();
findExpandDown
(
).
click
(
);
findExpandDown
(
wrapper
).
trigger
(
'
click
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/loadMoreLines
'
,
{
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/loadMoreLines
'
,
{
endpoint
:
'
contextLinesPath
'
,
endpoint
:
'
contextLinesPath
'
,
...
...
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