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
49d27c90
Commit
49d27c90
authored
Jul 11, 2021
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor viewer spec & add empty viewer scenario
Convert viewer spec into it block. Add empty viewer scenario.
parent
ce2b5a1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
36 deletions
+32
-36
spec/frontend/repository/components/blob_content_viewer_spec.js
...rontend/repository/components/blob_content_viewer_spec.js
+32
-36
No files found.
spec/frontend/repository/components/blob_content_viewer_spec.js
View file @
49d27c90
...
...
@@ -13,6 +13,7 @@ import BlobContentViewer from '~/repository/components/blob_content_viewer.vue';
import
BlobEdit
from
'
~/repository/components/blob_edit.vue
'
;
import
{
loadViewer
,
viewerProps
}
from
'
~/repository/components/blob_viewers
'
;
import
DownloadViewer
from
'
~/repository/components/blob_viewers/download_viewer.vue
'
;
import
EmptyViewer
from
'
~/repository/components/blob_viewers/empty_viewer.vue
'
;
import
TextViewer
from
'
~/repository/components/blob_viewers/text_viewer.vue
'
;
import
blobInfoQuery
from
'
~/repository/queries/blob_info.query.graphql
'
;
...
...
@@ -124,8 +125,6 @@ describe('Blob content viewer component', () => {
const
findBlobEdit
=
()
=>
wrapper
.
findComponent
(
BlobEdit
);
const
findBlobContent
=
()
=>
wrapper
.
findComponent
(
BlobContent
);
const
findBlobButtonGroup
=
()
=>
wrapper
.
findComponent
(
BlobButtonGroup
);
const
findTextViewer
=
()
=>
wrapper
.
findComponent
(
TextViewer
);
const
findDownloadViewer
=
()
=>
wrapper
.
findComponent
(
DownloadViewer
);
afterEach
(()
=>
{
wrapper
.
destroy
();
...
...
@@ -225,9 +224,9 @@ describe('Blob content viewer component', () => {
});
describe
(
'
Blob viewer
'
,
()
=>
{
before
Each
(()
=>
{
loadViewer
.
mock
Clear
();
viewerProps
.
mock
Clear
();
after
Each
(()
=>
{
loadViewer
.
mock
Restore
();
viewerProps
.
mock
Restore
();
});
it
(
'
does not render a BlobContent component if a Blob viewer is available
'
,
()
=>
{
...
...
@@ -237,39 +236,36 @@ describe('Blob content viewer component', () => {
expect
(
findBlobContent
().
exists
()).
toBe
(
false
);
});
it
(
'
renders a TextViewer for text files
'
,
()
=>
{
loadViewer
.
mockReturnValueOnce
(
TextViewer
);
viewerProps
.
mockReturnValueOnce
({
content
:
'
test
'
,
fileName
:
'
test.js
'
,
readOnly
:
true
});
factory
({
mockData
:
{
blobInfo
:
simpleMockData
}
});
expect
(
findTextViewer
().
exists
()).
toBe
(
true
);
});
it
(
'
renders a DownloadViewer for download files
'
,
async
()
=>
{
loadViewer
.
mockReturnValue
(
DownloadViewer
);
viewerProps
.
mockReturnValue
({
filePath
:
'
/some/file/path
'
,
fileName
:
'
test.js
'
,
fileSize
:
100
,
});
const
downloadSimpleMockData
=
{
...
simpleMockData
,
fileType
:
null
,
simpleViewer
:
{
...
simpleMockData
.
simpleViewer
,
fileType
:
'
download
'
,
},
};
factory
({
mockData
:
{
blobInfo
:
downloadSimpleMockData
}
});
it
.
each
`
viewer | loadViewerReturnValue | viewerPropsReturnValue
${
'
empty
'
}
|
${
EmptyViewer
}
|
${{}}
$
{
'
download
'
}
|
${
DownloadViewer
}
|
${{
filePath
:
'
/some/file/path
'
,
fileName
:
'
test.js
'
,
fileSize
:
100
}
}
${
'
text
'
}
|
${
TextViewer
}
|
${{
content
:
'
test
'
,
fileName
:
'
test.js
'
,
readOnly
:
true
}
}
`
(
'
renders viewer component for $viewer files
'
,
async
({
viewer
,
loadViewerReturnValue
,
viewerPropsReturnValue
})
=>
{
loadViewer
.
mockReturnValue
(
loadViewerReturnValue
);
viewerProps
.
mockReturnValue
(
viewerPropsReturnValue
);
factory
({
mockData
:
{
blobInfo
:
{
...
simpleMockData
,
fileType
:
null
,
simpleViewer
:
{
...
simpleMockData
.
simpleViewer
,
fileType
:
viewer
,
},
},
},
});
await
nextTick
();
await
nextTick
();
expect
(
loadViewer
).
toHaveBeenCalledWith
(
'
download
'
);
expect
(
findDownloadViewer
().
exists
()).
toBe
(
true
);
});
expect
(
loadViewer
).
toHaveBeenCalledWith
(
viewer
);
expect
(
wrapper
.
findComponent
(
loadViewerReturnValue
).
exists
()).
toBe
(
true
);
},
);
});
describe
(
'
BlobHeader action slot
'
,
()
=>
{
...
...
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