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
aba59df1
Commit
aba59df1
authored
Aug 12, 2021
by
Denys Mishunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of the spec
As per review
parent
2fffee26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
spec/frontend/editor/source_editor_markdown_ext_spec.js
spec/frontend/editor/source_editor_markdown_ext_spec.js
+13
-16
No files found.
spec/frontend/editor/source_editor_markdown_ext_spec.js
View file @
aba59df1
...
...
@@ -36,6 +36,11 @@ describe('Markdown Extension for Source Editor', () => {
const
selectionToString
=
()
=>
instance
.
getSelection
().
toString
();
const
positionToString
=
()
=>
instance
.
getPosition
().
toString
();
const
togglePreview
=
async
()
=>
{
instance
.
togglePreview
();
await
waitForPromises
();
};
beforeEach
(()
=>
{
setFixtures
(
'
<div id="editor" data-editor-loading></div>
'
);
editorEl
=
document
.
getElementById
(
'
editor
'
);
...
...
@@ -159,38 +164,32 @@ describe('Markdown Extension for Source Editor', () => {
});
it
(
'
toggles visibility of the preview DOM element
'
,
async
()
=>
{
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
instance
.
previewEl
.
style
.
display
).
toBe
(
'
block
'
);
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
instance
.
previewEl
.
style
.
display
).
toBe
(
'
none
'
);
});
describe
(
'
hidden preview DOM element
'
,
()
=>
{
it
(
'
shows error notification if fetching content fails
'
,
async
()
=>
{
axios
.
post
.
mockImplementation
(()
=>
Promise
.
reject
());
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
createFlash
).
toHaveBeenCalled
();
});
it
(
'
fetches preview content and puts into the preview DOM element
'
,
async
()
=>
{
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
instance
.
previewEl
.
innerHTML
).
toEqual
(
responseData
);
});
it
(
'
applies syntax highlighting to the preview content
'
,
async
()
=>
{
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
syntaxHighlight
).
toHaveBeenCalled
();
});
it
(
'
listens to model changes and re-fetches preview
'
,
async
()
=>
{
expect
(
axios
.
post
).
not
.
toHaveBeenCalled
();
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
axios
.
post
).
toHaveBeenCalledTimes
(
1
);
instance
.
setValue
(
'
New Value
'
);
...
...
@@ -200,16 +199,14 @@ describe('Markdown Extension for Source Editor', () => {
it
(
'
stores disposable listener for model changes
'
,
async
()
=>
{
expect
(
instance
.
modelChangeListener
).
toBeUndefined
();
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
expect
(
instance
.
modelChangeListener
).
toBeDefined
();
});
});
describe
(
'
already visible preview
'
,
()
=>
{
beforeEach
(
async
()
=>
{
instance
.
togglePreview
();
await
waitForPromises
();
await
togglePreview
();
jest
.
clearAllMocks
();
});
...
...
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