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
5d407faa
Commit
5d407faa
authored
Dec 24, 2020
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated `methods` usage
- replace with parentComponent
parent
5dc5bd3b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
129 deletions
+99
-129
spec/frontend/diffs/components/app_spec.js
spec/frontend/diffs/components/app_spec.js
+94
-126
spec/frontend/diffs/components/image_diff_overlay_spec.js
spec/frontend/diffs/components/image_diff_overlay_spec.js
+5
-3
No files found.
spec/frontend/diffs/components/app_spec.js
View file @
5d407faa
import
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
,
GlPagination
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlPagination
}
from
'
@gitlab/ui
'
;
...
@@ -53,7 +54,7 @@ describe('diffs/components/app', () => {
...
@@ -53,7 +54,7 @@ describe('diffs/components/app', () => {
extendStore
(
store
);
extendStore
(
store
);
wrapper
=
shallowMount
(
localVue
.
extend
(
App
)
,
{
wrapper
=
shallowMount
(
App
,
{
localVue
,
localVue
,
propsData
:
{
propsData
:
{
endpoint
:
TEST_ENDPOINT
,
endpoint
:
TEST_ENDPOINT
,
...
@@ -70,11 +71,6 @@ describe('diffs/components/app', () => {
...
@@ -70,11 +71,6 @@ describe('diffs/components/app', () => {
},
},
provide
,
provide
,
store
,
store
,
methods
:
{
isLatestVersion
()
{
return
true
;
},
},
});
});
}
}
...
@@ -102,7 +98,7 @@ describe('diffs/components/app', () => {
...
@@ -102,7 +98,7 @@ describe('diffs/components/app', () => {
});
});
describe
(
'
fetch diff methods
'
,
()
=>
{
describe
(
'
fetch diff methods
'
,
()
=>
{
beforeEach
((
done
)
=>
{
beforeEach
(()
=>
{
const
fetchResolver
=
()
=>
{
const
fetchResolver
=
()
=>
{
store
.
state
.
diffs
.
retrievingBatches
=
false
;
store
.
state
.
diffs
.
retrievingBatches
=
false
;
store
.
state
.
notes
.
discussions
=
'
test
'
;
store
.
state
.
notes
.
discussions
=
'
test
'
;
...
@@ -119,15 +115,15 @@ describe('diffs/components/app', () => {
...
@@ -119,15 +115,15 @@ describe('diffs/components/app', () => {
jest
.
spyOn
(
wrapper
.
vm
,
'
unwatchRetrievingBatches
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
wrapper
.
vm
,
'
unwatchRetrievingBatches
'
).
mockImplementation
(()
=>
{});
store
.
state
.
diffs
.
retrievingBatches
=
true
;
store
.
state
.
diffs
.
retrievingBatches
=
true
;
store
.
state
.
diffs
.
diffFiles
=
[];
store
.
state
.
diffs
.
diffFiles
=
[];
wrapper
.
vm
.
$nextTick
(
done
);
return
nextTick
(
);
});
});
it
(
'
calls batch methods if diffsBatchLoad is enabled, and not latest version
'
,
(
done
)
=>
{
it
(
'
calls batch methods if diffsBatchLoad is enabled, and not latest version
'
,
async
(
)
=>
{
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
0
);
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
0
);
wrapper
.
vm
.
isLatestVersion
=
()
=>
false
;
wrapper
.
vm
.
fetchData
(
false
);
wrapper
.
vm
.
fetchData
(
false
);
setImmediate
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
startRenderDiffsQueue
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
startRenderDiffsQueue
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesMeta
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesMeta
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesBatch
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesBatch
).
toHaveBeenCalled
();
...
@@ -135,15 +131,14 @@ describe('diffs/components/app', () => {
...
@@ -135,15 +131,14 @@ describe('diffs/components/app', () => {
expect
(
wrapper
.
vm
.
unwatchDiscussions
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
unwatchDiscussions
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
100
);
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
100
);
expect
(
wrapper
.
vm
.
unwatchRetrievingBatches
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
unwatchRetrievingBatches
).
toHaveBeenCalled
();
done
();
});
});
});
it
(
'
calls batch methods if diffsBatchLoad is enabled, and latest version
'
,
(
done
)
=>
{
it
(
'
calls batch methods if diffsBatchLoad is enabled, and latest version
'
,
async
(
)
=>
{
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
0
);
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
0
);
wrapper
.
vm
.
fetchData
(
false
);
wrapper
.
vm
.
fetchData
(
false
);
setImmediate
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
startRenderDiffsQueue
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
startRenderDiffsQueue
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesMeta
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesMeta
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesBatch
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
fetchDiffFilesBatch
).
toHaveBeenCalled
();
...
@@ -151,8 +146,6 @@ describe('diffs/components/app', () => {
...
@@ -151,8 +146,6 @@ describe('diffs/components/app', () => {
expect
(
wrapper
.
vm
.
unwatchDiscussions
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
unwatchDiscussions
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
100
);
expect
(
wrapper
.
vm
.
diffFilesLength
).
toEqual
(
100
);
expect
(
wrapper
.
vm
.
unwatchRetrievingBatches
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
unwatchRetrievingBatches
).
toHaveBeenCalled
();
done
();
});
});
});
});
});
...
@@ -216,30 +209,27 @@ describe('diffs/components/app', () => {
...
@@ -216,30 +209,27 @@ describe('diffs/components/app', () => {
window
.
location
.
hash
=
'
ABC_123
'
;
window
.
location
.
hash
=
'
ABC_123
'
;
});
});
it
(
'
sets highlighted row if hash exists in location object
'
,
(
done
)
=>
{
it
(
'
sets highlighted row if hash exists in location object
'
,
async
(
)
=>
{
createComponent
({
createComponent
({
shouldShow
:
true
,
shouldShow
:
true
,
});
});
// Component uses $nextTick so we wait until that has finished
// Component uses $nextTick so we wait until that has finished
setImmediate
(()
=>
{
await
nextTick
();
expect
(
store
.
state
.
diffs
.
highlightedRow
).
toBe
(
'
ABC_123
'
);
done
();
expect
(
store
.
state
.
diffs
.
highlightedRow
).
toBe
(
'
ABC_123
'
);
});
});
});
it
(
'
marks current diff file based on currently highlighted row
'
,
()
=>
{
it
(
'
marks current diff file based on currently highlighted row
'
,
async
()
=>
{
createComponent
({
createComponent
({
shouldShow
:
true
,
shouldShow
:
true
,
});
});
// Component uses $nextTick so we wait until that has finished
// Component uses $nextTick so we wait until that has finished
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
store
.
state
.
diffs
.
currentDiffFileId
).
toBe
(
'
ABC
'
);
expect
(
store
.
state
.
diffs
.
currentDiffFileId
).
toBe
(
'
ABC
'
);
});
});
});
});
});
describe
(
'
resizable
'
,
()
=>
{
describe
(
'
resizable
'
,
()
=>
{
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -267,17 +257,15 @@ describe('diffs/components/app', () => {
...
@@ -267,17 +257,15 @@ describe('diffs/components/app', () => {
});
});
});
});
it
(
'
marks current diff file based on currently highlighted row
'
,
(
done
)
=>
{
it
(
'
marks current diff file based on currently highlighted row
'
,
async
(
)
=>
{
createComponent
({
createComponent
({
shouldShow
:
true
,
shouldShow
:
true
,
});
});
// Component uses $nextTick so we wait until that has finished
// Component uses $nextTick so we wait until that has finished
setImmediate
(()
=>
{
await
nextTick
();
expect
(
store
.
state
.
diffs
.
currentDiffFileId
).
toBe
(
'
ABC
'
);
done
();
expect
(
store
.
state
.
diffs
.
currentDiffFileId
).
toBe
(
'
ABC
'
);
});
});
});
describe
(
'
empty state
'
,
()
=>
{
describe
(
'
empty state
'
,
()
=>
{
...
@@ -341,16 +329,15 @@ describe('diffs/components/app', () => {
...
@@ -341,16 +329,15 @@ describe('diffs/components/app', () => {
${
'
c
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${[{
direction
:
'
next
'
}]}
|
${{
mrCommitNeighborNav
:
true
}
}
${
'
c
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${[{
direction
:
'
next
'
}]}
|
${{
mrCommitNeighborNav
:
true
}
}
`
(
`
(
'
calls `$name()` with correct parameters whenever the "$key" key is pressed
'
,
'
calls `$name()` with correct parameters whenever the "$key" key is pressed
'
,
({
key
,
spy
,
args
,
featureFlags
})
=>
{
async
({
key
,
spy
,
args
,
featureFlags
})
=>
{
setup
({
shouldShow
:
true
},
featureFlags
);
setup
({
shouldShow
:
true
},
featureFlags
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
Mousetrap
.
trigger
(
key
);
Mousetrap
.
trigger
(
key
);
expect
(
spies
[
spy
]).
toHaveBeenCalledWith
(...
args
);
expect
(
spies
[
spy
]).
toHaveBeenCalledWith
(...
args
);
});
},
},
);
);
...
@@ -360,16 +347,15 @@ describe('diffs/components/app', () => {
...
@@ -360,16 +347,15 @@ describe('diffs/components/app', () => {
${
'
c
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${{
mrCommitNeighborNav
:
false
}
}
${
'
c
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${{
mrCommitNeighborNav
:
false
}
}
`
(
`
(
'
does not call `$name()` even when the correct key is pressed if the feature flag is disabled
'
,
'
does not call `$name()` even when the correct key is pressed if the feature flag is disabled
'
,
({
key
,
spy
,
featureFlags
})
=>
{
async
({
key
,
spy
,
featureFlags
})
=>
{
setup
({
shouldShow
:
true
},
featureFlags
);
setup
({
shouldShow
:
true
},
featureFlags
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
Mousetrap
.
trigger
(
key
);
Mousetrap
.
trigger
(
key
);
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
});
},
},
);
);
...
@@ -379,26 +365,24 @@ describe('diffs/components/app', () => {
...
@@ -379,26 +365,24 @@ describe('diffs/components/app', () => {
${
'
r
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${[
'
x
'
,
'
c
'
]}
${
'
r
'
}
|
${
'
moveToNeighboringCommit
'
}
|
${
1
}
|
${[
'
x
'
,
'
c
'
]}
`
(
`
(
`does not call \`$name()\` when a key that is not one of \`$allowed\` is pressed`
,
`does not call \`$name()\` when a key that is not one of \`$allowed\` is pressed`
,
({
key
,
spy
})
=>
{
async
({
key
,
spy
})
=>
{
setup
({
shouldShow
:
true
},
{
mrCommitNeighborNav
:
true
});
setup
({
shouldShow
:
true
},
{
mrCommitNeighborNav
:
true
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
Mousetrap
.
trigger
(
key
);
Mousetrap
.
trigger
(
key
);
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
expect
(
spies
[
spy
]).
not
.
toHaveBeenCalled
();
});
},
},
);
);
});
});
describe
(
'
hidden app
'
,
()
=>
{
describe
(
'
hidden app
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
setup
({
shouldShow
:
false
},
{
mrCommitNeighborNav
:
true
});
setup
({
shouldShow
:
false
},
{
mrCommitNeighborNav
:
true
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
Mousetrap
.
reset
();
Mousetrap
.
reset
();
});
});
});
it
.
each
`
it
.
each
`
key | name | spy
key | name | spy
...
@@ -439,10 +423,9 @@ describe('diffs/components/app', () => {
...
@@ -439,10 +423,9 @@ describe('diffs/components/app', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
jumps to next and previous files in the list
'
,
(
done
)
=>
{
it
(
'
jumps to next and previous files in the list
'
,
async
()
=>
{
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
wrapper
.
vm
.
jumpToFile
(
+
1
);
wrapper
.
vm
.
jumpToFile
(
+
1
);
expect
(
spy
.
mock
.
calls
[
spy
.
mock
.
calls
.
length
-
1
]).
toEqual
([
'
222.js
'
]);
expect
(
spy
.
mock
.
calls
[
spy
.
mock
.
calls
.
length
-
1
]).
toEqual
([
'
222.js
'
]);
...
@@ -454,15 +437,10 @@ describe('diffs/components/app', () => {
...
@@ -454,15 +437,10 @@ describe('diffs/components/app', () => {
wrapper
.
vm
.
jumpToFile
(
-
1
);
wrapper
.
vm
.
jumpToFile
(
-
1
);
expect
(
spy
.
mock
.
calls
[
spy
.
mock
.
calls
.
length
-
1
]).
toEqual
([
'
222.js
'
]);
expect
(
spy
.
mock
.
calls
[
spy
.
mock
.
calls
.
length
-
1
]).
toEqual
([
'
222.js
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
does not jump to previous file from the first one
'
,
(
done
)
=>
{
it
(
'
does not jump to previous file from the first one
'
,
async
()
=>
{
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
store
.
state
.
diffs
.
currentDiffFileId
=
'
333
'
;
store
.
state
.
diffs
.
currentDiffFileId
=
'
333
'
;
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
2
);
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
2
);
...
@@ -471,24 +449,16 @@ describe('diffs/components/app', () => {
...
@@ -471,24 +449,16 @@ describe('diffs/components/app', () => {
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
2
);
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
2
);
expect
(
spy
).
not
.
toHaveBeenCalled
();
expect
(
spy
).
not
.
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
does not jump to next file from the last one
'
,
(
done
)
=>
{
it
(
'
does not jump to next file from the last one
'
,
async
()
=>
{
wrapper
.
vm
await
nextTick
();
.
$nextTick
()
.
then
(()
=>
{
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
0
);
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
0
);
wrapper
.
vm
.
jumpToFile
(
-
1
);
wrapper
.
vm
.
jumpToFile
(
-
1
);
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
0
);
expect
(
wrapper
.
vm
.
currentDiffIndex
).
toEqual
(
0
);
expect
(
spy
).
not
.
toHaveBeenCalled
();
expect
(
spy
).
not
.
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
@@ -514,7 +484,7 @@ describe('diffs/components/app', () => {
...
@@ -514,7 +484,7 @@ describe('diffs/components/app', () => {
window
.
location
=
location
;
window
.
location
=
location
;
});
});
it
(
'
when the commit changes and the app is not loading it should update the history, refetch the diff data, and update the view
'
,
()
=>
{
it
(
'
when the commit changes and the app is not loading it should update the history, refetch the diff data, and update the view
'
,
async
()
=>
{
createComponent
({},
({
state
})
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
commit
=
{
...
state
.
diffs
.
commit
,
id
:
'
OLD
'
};
state
.
diffs
.
commit
=
{
...
state
.
diffs
.
commit
,
id
:
'
OLD
'
};
});
});
...
@@ -522,7 +492,7 @@ describe('diffs/components/app', () => {
...
@@ -522,7 +492,7 @@ describe('diffs/components/app', () => {
store
.
state
.
diffs
.
commit
=
{
id
:
'
NEW
'
};
store
.
state
.
diffs
.
commit
=
{
id
:
'
NEW
'
};
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
urlUtils
.
updateHistory
).
toHaveBeenCalledWith
({
expect
(
urlUtils
.
updateHistory
).
toHaveBeenCalledWith
({
title
:
document
.
title
,
title
:
document
.
title
,
url
:
UPDATED_COMMIT_URL
,
url
:
UPDATED_COMMIT_URL
,
...
@@ -530,7 +500,6 @@ describe('diffs/components/app', () => {
...
@@ -530,7 +500,6 @@ describe('diffs/components/app', () => {
expect
(
wrapper
.
vm
.
refetchDiffData
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
refetchDiffData
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
adjustView
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
adjustView
).
toHaveBeenCalled
();
});
});
});
it
.
each
`
it
.
each
`
isLoading | oldSha | newSha
isLoading | oldSha | newSha
...
@@ -538,7 +507,7 @@ describe('diffs/components/app', () => {
...
@@ -538,7 +507,7 @@ describe('diffs/components/app', () => {
${
false
}
|
${
'
NEW
'
}
|
${
'
NEW
'
}
${
false
}
|
${
'
NEW
'
}
|
${
'
NEW
'
}
`
(
`
(
'
given `{ "isLoading": $isLoading, "oldSha": "$oldSha", "newSha": "$newSha" }`, nothing should happen
'
,
'
given `{ "isLoading": $isLoading, "oldSha": "$oldSha", "newSha": "$newSha" }`, nothing should happen
'
,
({
isLoading
,
oldSha
,
newSha
})
=>
{
async
({
isLoading
,
oldSha
,
newSha
})
=>
{
createComponent
({},
({
state
})
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
isLoading
=
isLoading
;
state
.
diffs
.
isLoading
=
isLoading
;
state
.
diffs
.
commit
=
{
...
state
.
diffs
.
commit
,
id
:
oldSha
};
state
.
diffs
.
commit
=
{
...
state
.
diffs
.
commit
,
id
:
oldSha
};
...
@@ -547,11 +516,10 @@ describe('diffs/components/app', () => {
...
@@ -547,11 +516,10 @@ describe('diffs/components/app', () => {
store
.
state
.
diffs
.
commit
=
{
id
:
newSha
};
store
.
state
.
diffs
.
commit
=
{
id
:
newSha
};
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
await
nextTick
();
expect
(
urlUtils
.
updateHistory
).
not
.
toHaveBeenCalled
();
expect
(
urlUtils
.
updateHistory
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
refetchDiffData
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
refetchDiffData
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
adjustView
).
not
.
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
adjustView
).
not
.
toHaveBeenCalled
();
});
},
},
);
);
});
});
...
@@ -710,7 +678,7 @@ describe('diffs/components/app', () => {
...
@@ -710,7 +678,7 @@ describe('diffs/components/app', () => {
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
312
'
});
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
312
'
});
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
findAll
(
DiffFile
).
length
).
toBe
(
1
);
expect
(
wrapper
.
findAll
(
DiffFile
).
length
).
toBe
(
1
);
});
});
...
@@ -724,7 +692,7 @@ describe('diffs/components/app', () => {
...
@@ -724,7 +692,7 @@ describe('diffs/components/app', () => {
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
123
'
},
{
file_hash
:
'
312
'
});
state
.
diffs
.
diffFiles
.
push
({
file_hash
:
'
123
'
},
{
file_hash
:
'
312
'
});
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
undefined
);
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
undefined
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
'
2
'
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
'
2
'
);
...
@@ -736,7 +704,7 @@ describe('diffs/components/app', () => {
...
@@ -736,7 +704,7 @@ describe('diffs/components/app', () => {
state
.
diffs
.
currentDiffFileId
=
'
312
'
;
state
.
diffs
.
currentDiffFileId
=
'
312
'
;
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
'
1
'
);
expect
(
paginator
().
attributes
(
'
prevpage
'
)).
toBe
(
'
1
'
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
undefined
);
expect
(
paginator
().
attributes
(
'
nextpage
'
)).
toBe
(
undefined
);
...
@@ -748,7 +716,7 @@ describe('diffs/components/app', () => {
...
@@ -748,7 +716,7 @@ describe('diffs/components/app', () => {
state
.
diffs
.
currentDiffFileId
=
'
123
'
;
state
.
diffs
.
currentDiffFileId
=
'
123
'
;
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
fileByFileNav
().
exists
()).
toBe
(
false
);
expect
(
fileByFileNav
().
exists
()).
toBe
(
false
);
});
});
...
@@ -765,13 +733,13 @@ describe('diffs/components/app', () => {
...
@@ -765,13 +733,13 @@ describe('diffs/components/app', () => {
state
.
diffs
.
currentDiffFileId
=
currentDiffFileId
;
state
.
diffs
.
currentDiffFileId
=
currentDiffFileId
;
});
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
jest
.
spyOn
(
wrapper
.
vm
,
'
navigateToDiffFileIndex
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
navigateToDiffFileIndex
'
);
paginator
().
vm
.
$emit
(
'
input
'
,
targetFile
);
paginator
().
vm
.
$emit
(
'
input
'
,
targetFile
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
wrapper
.
vm
.
navigateToDiffFileIndex
).
toHaveBeenCalledWith
(
targetFile
-
1
);
expect
(
wrapper
.
vm
.
navigateToDiffFileIndex
).
toHaveBeenCalledWith
(
targetFile
-
1
);
},
},
...
@@ -787,10 +755,10 @@ describe('diffs/components/app', () => {
...
@@ -787,10 +755,10 @@ describe('diffs/components/app', () => {
'
triggers the action with the new fileByFile setting - $setting - when the event with that setting is received
'
,
'
triggers the action with the new fileByFile setting - $setting - when the event with that setting is received
'
,
async
({
setting
})
=>
{
async
({
setting
})
=>
{
createComponent
();
createComponent
();
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
eventHub
.
$emit
(
EVT_VIEW_FILE_BY_FILE
,
{
setting
});
eventHub
.
$emit
(
EVT_VIEW_FILE_BY_FILE
,
{
setting
});
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
store
.
state
.
diffs
.
viewDiffsFileByFile
).
toBe
(
setting
);
expect
(
store
.
state
.
diffs
.
viewDiffsFileByFile
).
toBe
(
setting
);
},
},
...
...
spec/frontend/diffs/components/image_diff_overlay_spec.js
View file @
5d407faa
...
@@ -21,6 +21,11 @@ describe('Diffs image diff overlay component', () => {
...
@@ -21,6 +21,11 @@ describe('Diffs image diff overlay component', () => {
wrapper
=
shallowMount
(
ImageDiffOverlay
,
{
wrapper
=
shallowMount
(
ImageDiffOverlay
,
{
store
,
store
,
parentComponent
:
{
data
()
{
return
dimensions
;
},
},
propsData
:
{
propsData
:
{
discussions
:
[...
imageDiffDiscussions
],
discussions
:
[...
imageDiffDiscussions
],
fileHash
:
'
ABC
'
,
fileHash
:
'
ABC
'
,
...
@@ -28,9 +33,6 @@ describe('Diffs image diff overlay component', () => {
...
@@ -28,9 +33,6 @@ describe('Diffs image diff overlay component', () => {
renderedHeight
:
200
,
renderedHeight
:
200
,
...
props
,
...
props
,
},
},
methods
:
{
getImageDimensions
:
jest
.
fn
().
mockReturnValue
(
dimensions
),
},
});
});
}
}
...
...
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