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
327e2b2a
Commit
327e2b2a
authored
Feb 03, 2021
by
Denys Mishunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better expectations in the spec
As per review
parent
dd5a2473
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
spec/frontend/editor/editor_lite_spec.js
spec/frontend/editor/editor_lite_spec.js
+15
-14
No files found.
spec/frontend/editor/editor_lite_spec.js
View file @
327e2b2a
...
...
@@ -57,7 +57,7 @@ describe('Base editor', () => {
const
mockModelReturn
=
(
res
=
fakeModel
)
=>
{
modelSpy
=
jest
.
spyOn
(
monacoEditor
,
'
createModel
'
).
mockImplementation
(()
=>
res
);
};
const
mockDecorateInstance
=
(
decorations
)
=>
{
const
mockDecorateInstance
=
(
decorations
=
{}
)
=>
{
jest
.
spyOn
(
EditorLite
,
'
convertMonacoToELInstance
'
).
mockImplementation
((
inst
)
=>
{
return
Object
.
assign
(
inst
,
decorations
);
});
...
...
@@ -70,12 +70,10 @@ describe('Base editor', () => {
describe
(
'
instance of the Code Editor
'
,
()
=>
{
beforeEach
(()
=>
{
instanceSpy
=
jest
.
spyOn
(
monacoEditor
,
'
create
'
);
mockDecorateInstance
({
setModel
,
});
});
it
(
'
throws an error if no dom element is supplied
'
,
()
=>
{
mockDecorateInstance
();
expect
(()
=>
{
editor
.
createInstance
();
}).
toThrow
(
EDITOR_LITE_INSTANCE_ERROR_NO_EL
);
...
...
@@ -87,6 +85,9 @@ describe('Base editor', () => {
it
(
'
creates model to be supplied to Monaco editor
'
,
()
=>
{
mockModelReturn
();
mockDecorateInstance
({
setModel
,
});
editor
.
createInstance
(
defaultArguments
);
expect
(
modelSpy
).
toHaveBeenCalledWith
(
...
...
@@ -100,6 +101,9 @@ describe('Base editor', () => {
});
it
(
'
does not create a model automatically if model is passed as `null`
'
,
()
=>
{
mockDecorateInstance
({
setModel
,
});
editor
.
createInstance
({
...
defaultArguments
,
model
:
null
});
expect
(
modelSpy
).
not
.
toHaveBeenCalled
();
expect
(
setModel
).
not
.
toHaveBeenCalled
();
...
...
@@ -153,6 +157,9 @@ describe('Base editor', () => {
it
(
"
removes the disposed instance from the global editor's storage and disposes the associated model
"
,
()
=>
{
mockModelReturn
();
mockDecorateInstance
({
setModel
,
});
const
instance
=
editor
.
createInstance
(
defaultArguments
);
expect
(
editor
.
instances
).
toHaveLength
(
1
);
...
...
@@ -168,9 +175,6 @@ describe('Base editor', () => {
describe
(
'
instance of the Diff Editor
'
,
()
=>
{
beforeEach
(()
=>
{
instanceSpy
=
jest
.
spyOn
(
monacoEditor
,
'
createDiffEditor
'
);
mockDecorateInstance
({
setModel
,
});
});
it
(
'
Diff Editor goes through the normal path of Code Editor just with the flag ON
'
,
()
=>
{
...
...
@@ -193,7 +197,8 @@ describe('Base editor', () => {
});
it
(
'
creates correct model for the Diff Editor
'
,
()
=>
{
editor
.
createDiffInstance
({
...
defaultArguments
,
blobOriginalContent
});
const
instance
=
editor
.
createDiffInstance
({
...
defaultArguments
,
blobOriginalContent
});
const
getDiffModelValue
=
(
model
)
=>
instance
.
getModel
()[
model
].
getValue
();
expect
(
modelSpy
).
toHaveBeenCalledTimes
(
2
);
expect
(
modelSpy
.
mock
.
calls
[
0
]).
toEqual
([
...
...
@@ -204,12 +209,8 @@ describe('Base editor', () => {
}),
]);
expect
(
modelSpy
.
mock
.
calls
[
1
]).
toEqual
([
blobOriginalContent
,
'
markdown
'
]);
expect
(
setModel
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
original
:
expect
.
anything
(),
modified
:
expect
.
anything
(),
}),
);
expect
(
getDiffModelValue
(
'
original
'
)).
toBe
(
blobOriginalContent
);
expect
(
getDiffModelValue
(
'
modified
'
)).
toBe
(
blobContent
);
});
it
(
'
correctly disposes the diff editor model
'
,
()
=>
{
...
...
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