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
ff156d48
Commit
ff156d48
authored
Aug 20, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test using the pagination component instead of custom buttons
parent
0ffdf51d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
spec/frontend/diffs/components/app_spec.js
spec/frontend/diffs/components/app_spec.js
+17
-14
No files found.
spec/frontend/diffs/components/app_spec.js
View file @
ff156d48
import
Vuex
from
'
vuex
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlPagination
}
from
'
@gitlab/ui
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
Mousetrap
from
'
mousetrap
'
;
...
...
@@ -843,13 +843,16 @@ describe('diffs/components/app', () => {
});
describe
(
'
pagination
'
,
()
=>
{
const
fileByFileNav
=
()
=>
wrapper
.
find
(
'
[data-testid="file-by-file-navigation"]
'
);
const
paginator
=
()
=>
fileByFileNav
().
find
(
GlPagination
);
it
(
'
sets previous button as disabled
'
,
()
=>
{
createComponent
({
viewDiffsFileByFile
:
true
},
({
state
})
=>
{
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
123
'
},
{
file_hash
:
'
312
'
});
});
expect
(
wrapper
.
find
(
'
[data-testid="singleFilePrevious"]
'
).
props
(
'
disabled
'
)).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="singleFileNext"]
'
).
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
undefined
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
'
2
'
);
});
it
(
'
sets next button as disabled
'
,
()
=>
{
...
...
@@ -858,17 +861,17 @@ describe('diffs/components/app', () => {
state
.
diffs
.
currentDiffFileId
=
'
312
'
;
});
expect
(
wrapper
.
find
(
'
[data-testid="singleFilePrevious"]
'
).
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
[data-testid="singleFileNext"]
'
).
props
(
'
disabled
'
)).
toBe
(
true
);
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
'
1
'
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
undefined
);
});
it
.
each
`
currentDiffFileId |
button | index
${
'
123
'
}
|
${
'
singleFileNext
'
}
|
${
1
}
${
'
312
'
}
|
${
'
singleFilePrevious
'
}
|
${
0
}
currentDiffFileId |
targetFile
${
'
123
'
}
|
${
2
}
${
'
312
'
}
|
${
1
}
`
(
'
it calls navigateToDiffFileIndex with $index when $
button
is clicked
'
,
({
currentDiffFileId
,
button
,
index
})
=>
{
'
it calls navigateToDiffFileIndex with $index when $
link
is clicked
'
,
async
({
currentDiffFileId
,
targetFile
})
=>
{
createComponent
({
viewDiffsFileByFile
:
true
},
({
state
})
=>
{
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
123
'
},
{
file_hash
:
'
312
'
});
state
.
diffs
.
currentDiffFileId
=
currentDiffFileId
;
...
...
@@ -876,11 +879,11 @@ describe('diffs/components/app', () => {
jest
.
spyOn
(
wrapper
.
vm
,
'
navigateToDiffFileIndex
'
);
wrapper
.
find
(
`[data-testid="
${
button
}
"]`
).
vm
.
$emit
(
'
click
'
);
paginator
().
vm
.
$emit
(
'
input
'
,
targetFile
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
wrapper
.
vm
.
navigateToDiffFileIndex
).
toHaveBeenCalledWith
(
index
);
}
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
navigateToDiffFileIndex
).
toHaveBeenCalledWith
(
targetFile
-
1
);
},
);
});
...
...
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