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
280a79c0
Commit
280a79c0
authored
Dec 23, 2020
by
Lukas Eipert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run prettier on 31 files - 60 of 73
Part of our prettier migration; changing the arrow-parens style.
parent
e94556e9
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
173 additions
and
206 deletions
+173
-206
.prettierignore
.prettierignore
+0
-33
spec/frontend/ide/components/repo_commit_section_spec.js
spec/frontend/ide/components/repo_commit_section_spec.js
+6
-6
spec/frontend/ide/components/repo_editor_spec.js
spec/frontend/ide/components/repo_editor_spec.js
+27
-27
spec/frontend/ide/components/repo_tabs_spec.js
spec/frontend/ide/components/repo_tabs_spec.js
+1
-1
spec/frontend/ide/components/resizable_panel_spec.js
spec/frontend/ide/components/resizable_panel_spec.js
+1
-1
spec/frontend/ide/components/shared/tokened_input_spec.js
spec/frontend/ide/components/shared/tokened_input_spec.js
+3
-3
spec/frontend/ide/components/terminal/session_spec.js
spec/frontend/ide/components/terminal/session_spec.js
+2
-2
spec/frontend/ide/components/terminal/terminal_controls_spec.js
...rontend/ide/components/terminal/terminal_controls_spec.js
+1
-1
spec/frontend/ide/components/terminal/terminal_spec.js
spec/frontend/ide/components/terminal/terminal_spec.js
+3
-3
spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js
...ide/components/terminal_sync/terminal_sync_status_spec.js
+1
-1
spec/frontend/ide/file_helpers.js
spec/frontend/ide/file_helpers.js
+1
-1
spec/frontend/ide/helpers.js
spec/frontend/ide/helpers.js
+3
-3
spec/frontend/ide/ide_router_extension_spec.js
spec/frontend/ide/ide_router_extension_spec.js
+2
-2
spec/frontend/ide/ide_router_spec.js
spec/frontend/ide/ide_router_spec.js
+1
-1
spec/frontend/ide/lib/common/model_spec.js
spec/frontend/ide/lib/common/model_spec.js
+1
-1
spec/frontend/ide/lib/create_diff_spec.js
spec/frontend/ide/lib/create_diff_spec.js
+4
-4
spec/frontend/ide/lib/create_file_diff_spec.js
spec/frontend/ide/lib/create_file_diff_spec.js
+4
-4
spec/frontend/ide/lib/diff/controller_spec.js
spec/frontend/ide/lib/diff/controller_spec.js
+2
-2
spec/frontend/ide/lib/editor_spec.js
spec/frontend/ide/lib/editor_spec.js
+1
-1
spec/frontend/ide/lib/editorconfig/parser_spec.js
spec/frontend/ide/lib/editorconfig/parser_spec.js
+3
-3
spec/frontend/ide/lib/errors_spec.js
spec/frontend/ide/lib/errors_spec.js
+1
-1
spec/frontend/ide/lib/files_spec.js
spec/frontend/ide/lib/files_spec.js
+3
-3
spec/frontend/ide/lib/mirror_spec.js
spec/frontend/ide/lib/mirror_spec.js
+2
-2
spec/frontend/ide/services/index_spec.js
spec/frontend/ide/services/index_spec.js
+10
-10
spec/frontend/ide/stores/actions/file_spec.js
spec/frontend/ide/stores/actions/file_spec.js
+5
-5
spec/frontend/ide/stores/actions/merge_request_spec.js
spec/frontend/ide/stores/actions/merge_request_spec.js
+18
-18
spec/frontend/ide/stores/actions/project_spec.js
spec/frontend/ide/stores/actions/project_spec.js
+15
-15
spec/frontend/ide/stores/actions/tree_spec.js
spec/frontend/ide/stores/actions/tree_spec.js
+5
-5
spec/frontend/ide/stores/actions_spec.js
spec/frontend/ide/stores/actions_spec.js
+43
-43
spec/frontend/ide/stores/extend_spec.js
spec/frontend/ide/stores/extend_spec.js
+2
-2
spec/frontend/ide/stores/getters_spec.js
spec/frontend/ide/stores/getters_spec.js
+1
-1
spec/frontend/ide/stores/integration_spec.js
spec/frontend/ide/stores/integration_spec.js
+1
-1
No files found.
.prettierignore
View file @
280a79c0
...
...
@@ -1887,39 +1887,6 @@ spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_using_real_timer.js
## jovial-mirzakhani
spec/frontend/ide/components/repo_commit_section_spec.js
spec/frontend/ide/components/repo_editor_spec.js
spec/frontend/ide/components/repo_tabs_spec.js
spec/frontend/ide/components/resizable_panel_spec.js
spec/frontend/ide/components/shared/tokened_input_spec.js
spec/frontend/ide/components/terminal/session_spec.js
spec/frontend/ide/components/terminal/terminal_controls_spec.js
spec/frontend/ide/components/terminal/terminal_spec.js
spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js
spec/frontend/ide/file_helpers.js
spec/frontend/ide/helpers.js
spec/frontend/ide/ide_router_extension_spec.js
spec/frontend/ide/ide_router_spec.js
spec/frontend/ide/lib/common/model_spec.js
spec/frontend/ide/lib/create_diff_spec.js
spec/frontend/ide/lib/create_file_diff_spec.js
spec/frontend/ide/lib/diff/controller_spec.js
spec/frontend/ide/lib/editor_spec.js
spec/frontend/ide/lib/editorconfig/parser_spec.js
spec/frontend/ide/lib/errors_spec.js
spec/frontend/ide/lib/files_spec.js
spec/frontend/ide/lib/mirror_spec.js
spec/frontend/ide/services/index_spec.js
spec/frontend/ide/stores/actions/file_spec.js
spec/frontend/ide/stores/actions/merge_request_spec.js
spec/frontend/ide/stores/actions/project_spec.js
spec/frontend/ide/stores/actions/tree_spec.js
spec/frontend/ide/stores/actions_spec.js
spec/frontend/ide/stores/extend_spec.js
spec/frontend/ide/stores/getters_spec.js
spec/frontend/ide/stores/integration_spec.js
## angry-bhabha
spec/frontend/ide/stores/modules/branches/actions_spec.js
spec/frontend/ide/stores/modules/branches/mutations_spec.js
...
...
spec/frontend/ide/components/repo_commit_section_spec.js
View file @
280a79c0
...
...
@@ -32,7 +32,7 @@ describe('RepoCommitSection', () => {
},
};
const
files
=
[
file
(
'
file1
'
),
file
(
'
file2
'
)].
map
(
f
=>
const
files
=
[
file
(
'
file1
'
),
file
(
'
file2
'
)].
map
(
(
f
)
=>
Object
.
assign
(
f
,
{
type
:
'
blob
'
,
content
:
'
orginal content
'
,
...
...
@@ -42,7 +42,7 @@ describe('RepoCommitSection', () => {
store
.
state
.
currentBranch
=
'
master
'
;
store
.
state
.
changedFiles
=
[];
store
.
state
.
stagedFiles
=
[{
...
files
[
0
]
},
{
...
files
[
1
]
}];
store
.
state
.
stagedFiles
.
forEach
(
f
=>
store
.
state
.
stagedFiles
.
forEach
(
(
f
)
=>
Object
.
assign
(
f
,
{
changed
:
true
,
staged
:
true
,
...
...
@@ -50,7 +50,7 @@ describe('RepoCommitSection', () => {
}),
);
files
.
forEach
(
f
=>
{
files
.
forEach
(
(
f
)
=>
{
store
.
state
.
entries
[
f
.
path
]
=
f
;
});
}
...
...
@@ -105,9 +105,9 @@ describe('RepoCommitSection', () => {
const
allFiles
=
store
.
state
.
changedFiles
.
concat
(
store
.
state
.
stagedFiles
);
const
changedFileNames
=
wrapper
.
findAll
(
'
.multi-file-commit-list > li
'
)
.
wrappers
.
map
(
x
=>
x
.
text
().
trim
());
.
wrappers
.
map
(
(
x
)
=>
x
.
text
().
trim
());
expect
(
changedFileNames
).
toEqual
(
allFiles
.
map
(
x
=>
x
.
path
));
expect
(
changedFileNames
).
toEqual
(
allFiles
.
map
(
(
x
)
=>
x
.
path
));
});
it
(
'
does not show empty state
'
,
()
=>
{
...
...
@@ -141,7 +141,7 @@ describe('RepoCommitSection', () => {
beforeEach
(()
=>
{
setupDefaultState
();
store
.
state
.
changedFiles
=
store
.
state
.
stagedFiles
.
map
(
x
=>
store
.
state
.
changedFiles
=
store
.
state
.
stagedFiles
.
map
(
(
x
)
=>
Object
.
assign
(
x
,
{
staged
:
false
}),
);
store
.
state
.
stagedFiles
=
[];
...
...
spec/frontend/ide/components/repo_editor_spec.js
View file @
280a79c0
...
...
@@ -25,7 +25,7 @@ describe('RepoEditor', () => {
let
store
;
const
waitForEditorSetup
=
()
=>
new
Promise
(
resolve
=>
{
new
Promise
(
(
resolve
)
=>
{
vm
.
$once
(
'
editorSetup
'
,
resolve
);
});
...
...
@@ -43,7 +43,7 @@ describe('RepoEditor', () => {
vm
.
$mount
();
};
const
createOpenFile
=
path
=>
{
const
createOpenFile
=
(
path
)
=>
{
const
origFile
=
store
.
state
.
openFiles
[
0
];
const
newFile
=
{
...
origFile
,
path
,
key
:
path
,
name
:
'
myfile.txt
'
,
content
:
'
hello world
'
};
...
...
@@ -91,7 +91,7 @@ describe('RepoEditor', () => {
});
const
findEditor
=
()
=>
vm
.
$el
.
querySelector
(
'
.multi-file-editor-holder
'
);
const
changeViewMode
=
viewMode
=>
const
changeViewMode
=
(
viewMode
)
=>
store
.
dispatch
(
'
editor/updateFileEditor
'
,
{
path
:
vm
.
file
.
path
,
data
:
{
viewMode
}
});
describe
(
'
default
'
,
()
=>
{
...
...
@@ -119,7 +119,7 @@ describe('RepoEditor', () => {
expect
(
findEditor
()).
not
.
toHaveCss
({
display
:
'
none
'
});
});
it
(
'
renders only an edit tab
'
,
done
=>
{
it
(
'
renders only an edit tab
'
,
(
done
)
=>
{
Vue
.
nextTick
(()
=>
{
const
tabs
=
vm
.
$el
.
querySelectorAll
(
'
.ide-mode-tabs .nav-links li
'
);
...
...
@@ -157,7 +157,7 @@ describe('RepoEditor', () => {
mock
.
restore
();
});
it
(
'
renders an Edit and a Preview Tab
'
,
done
=>
{
it
(
'
renders an Edit and a Preview Tab
'
,
(
done
)
=>
{
Vue
.
nextTick
(()
=>
{
const
tabs
=
vm
.
$el
.
querySelectorAll
(
'
.ide-mode-tabs .nav-links li
'
);
...
...
@@ -169,7 +169,7 @@ describe('RepoEditor', () => {
});
});
it
(
'
renders markdown for tempFile
'
,
done
=>
{
it
(
'
renders markdown for tempFile
'
,
(
done
)
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
$nextTick
()
...
...
@@ -202,7 +202,7 @@ describe('RepoEditor', () => {
});
describe
(
'
when open file is binary and not raw
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
(
done
)
=>
{
vm
.
file
.
name
=
'
file.dat
'
;
vm
.
file
.
content
=
'
🐱
'
;
// non-ascii binary content
jest
.
spyOn
(
vm
.
editor
,
'
createInstance
'
).
mockImplementation
();
...
...
@@ -227,7 +227,7 @@ describe('RepoEditor', () => {
});
describe
(
'
createEditorInstance
'
,
()
=>
{
it
(
'
calls createInstance when viewer is editor
'
,
done
=>
{
it
(
'
calls createInstance when viewer is editor
'
,
(
done
)
=>
{
jest
.
spyOn
(
vm
.
editor
,
'
createInstance
'
).
mockImplementation
();
vm
.
createEditorInstance
();
...
...
@@ -239,7 +239,7 @@ describe('RepoEditor', () => {
});
});
it
(
'
calls createDiffInstance when viewer is diff
'
,
done
=>
{
it
(
'
calls createDiffInstance when viewer is diff
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
viewer
=
'
diff
'
;
jest
.
spyOn
(
vm
.
editor
,
'
createDiffInstance
'
).
mockImplementation
();
...
...
@@ -253,7 +253,7 @@ describe('RepoEditor', () => {
});
});
it
(
'
calls createDiffInstance when viewer is a merge request diff
'
,
done
=>
{
it
(
'
calls createDiffInstance when viewer is a merge request diff
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
viewer
=
'
mrdiff
'
;
jest
.
spyOn
(
vm
.
editor
,
'
createDiffInstance
'
).
mockImplementation
();
...
...
@@ -354,7 +354,7 @@ describe('RepoEditor', () => {
jest
.
spyOn
(
vm
.
editor
,
'
updateDiffView
'
).
mockImplementation
();
});
it
(
'
calls updateDimensions when panelResizing is false
'
,
done
=>
{
it
(
'
calls updateDimensions when panelResizing is false
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
panelResizing
=
true
;
vm
.
$nextTick
()
...
...
@@ -370,7 +370,7 @@ describe('RepoEditor', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does not call updateDimensions when panelResizing is true
'
,
done
=>
{
it
(
'
does not call updateDimensions when panelResizing is true
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
panelResizing
=
true
;
vm
.
$nextTick
(()
=>
{
...
...
@@ -381,7 +381,7 @@ describe('RepoEditor', () => {
});
});
it
(
'
calls updateDimensions when rightPane is opened
'
,
done
=>
{
it
(
'
calls updateDimensions when rightPane is opened
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
rightPane
.
isOpen
=
true
;
vm
.
$nextTick
(()
=>
{
...
...
@@ -398,7 +398,7 @@ describe('RepoEditor', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.nav-links
'
)).
not
.
toBe
(
null
);
});
it
(
'
hides tabs in review mode
'
,
done
=>
{
it
(
'
hides tabs in review mode
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
.
review
.
name
;
vm
.
$nextTick
(()
=>
{
...
...
@@ -408,7 +408,7 @@ describe('RepoEditor', () => {
});
});
it
(
'
hides tabs in commit mode
'
,
done
=>
{
it
(
'
hides tabs in commit mode
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
currentActivityView
=
leftSidebarViews
.
commit
.
name
;
vm
.
$nextTick
(()
=>
{
...
...
@@ -420,7 +420,7 @@ describe('RepoEditor', () => {
});
describe
(
'
when files view mode is preview
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
(
done
)
=>
{
jest
.
spyOn
(
vm
.
editor
,
'
updateDimensions
'
).
mockImplementation
();
changeViewMode
(
FILE_VIEW_MODE_PREVIEW
);
vm
.
file
.
name
=
'
myfile.md
'
;
...
...
@@ -452,7 +452,7 @@ describe('RepoEditor', () => {
jest
.
spyOn
(
vm
,
'
shouldHideEditor
'
,
'
get
'
).
mockReturnValue
(
true
);
});
it
(
'
does not fetch file information for temp entries
'
,
done
=>
{
it
(
'
does not fetch file information for temp entries
'
,
(
done
)
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
initEditor
();
...
...
@@ -464,7 +464,7 @@ describe('RepoEditor', () => {
.
catch
(
done
.
fail
);
});
it
(
'
is being initialised for files without content even if shouldHideEditor is `true`
'
,
done
=>
{
it
(
'
is being initialised for files without content even if shouldHideEditor is `true`
'
,
(
done
)
=>
{
vm
.
file
.
content
=
''
;
vm
.
file
.
raw
=
''
;
...
...
@@ -479,7 +479,7 @@ describe('RepoEditor', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does not initialize editor for files already with content
'
,
done
=>
{
it
(
'
does not initialize editor for files already with content
'
,
(
done
)
=>
{
vm
.
file
.
content
=
'
foo
'
;
vm
.
initEditor
();
...
...
@@ -499,7 +499,7 @@ describe('RepoEditor', () => {
jest
.
spyOn
(
vm
,
'
initEditor
'
).
mockImplementation
();
});
it
(
'
calls removePendingTab when old file is pending
'
,
done
=>
{
it
(
'
calls removePendingTab when old file is pending
'
,
(
done
)
=>
{
jest
.
spyOn
(
vm
,
'
shouldHideEditor
'
,
'
get
'
).
mockReturnValue
(
true
);
jest
.
spyOn
(
vm
,
'
removePendingTab
'
).
mockImplementation
();
...
...
@@ -519,7 +519,7 @@ describe('RepoEditor', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does not call initEditor if the file did not change
'
,
done
=>
{
it
(
'
does not call initEditor if the file did not change
'
,
(
done
)
=>
{
Vue
.
set
(
vm
,
'
file
'
,
vm
.
file
);
vm
.
$nextTick
()
...
...
@@ -530,7 +530,7 @@ describe('RepoEditor', () => {
.
catch
(
done
.
fail
);
});
it
(
'
calls initEditor when file key is changed
'
,
done
=>
{
it
(
'
calls initEditor when file key is changed
'
,
(
done
)
=>
{
expect
(
vm
.
initEditor
).
not
.
toHaveBeenCalled
();
Vue
.
set
(
vm
,
'
file
'
,
{
...
...
@@ -552,7 +552,7 @@ describe('RepoEditor', () => {
vm
.
getRawFileData
.
mockRestore
();
});
const
createRemoteFile
=
name
=>
({
const
createRemoteFile
=
(
name
)
=>
({
...
file
(
name
),
tmpFile
:
false
,
});
...
...
@@ -605,7 +605,7 @@ describe('RepoEditor', () => {
});
describe
(
'
onPaste
'
,
()
=>
{
const
setFileName
=
name
=>
{
const
setFileName
=
(
name
)
=>
{
Vue
.
set
(
vm
,
'
file
'
,
{
...
vm
.
file
,
content
:
'
hello world
\n
'
,
...
...
@@ -627,8 +627,8 @@ describe('RepoEditor', () => {
);
};
const
watchState
=
watched
=>
new
Promise
(
resolve
=>
{
const
watchState
=
(
watched
)
=>
new
Promise
(
(
resolve
)
=>
{
const
unwatch
=
vm
.
$store
.
watch
(
watched
,
()
=>
{
unwatch
();
resolve
();
...
...
@@ -638,7 +638,7 @@ describe('RepoEditor', () => {
// Pasting an image does a lot of things like using the FileReader API,
// so, waitForPromises isn't very reliable (and causes a flaky spec)
// Read more about state.watch: https://vuex.vuejs.org/api/#watch
const
waitForFileContentChange
=
()
=>
watchState
(
s
=>
s
.
entries
[
'
foo/bar.md
'
].
content
);
const
waitForFileContentChange
=
()
=>
watchState
(
(
s
)
=>
s
.
entries
[
'
foo/bar.md
'
].
content
);
beforeEach
(()
=>
{
setFileName
(
'
bar.md
'
);
...
...
spec/frontend/ide/components/repo_tabs_spec.js
View file @
280a79c0
...
...
@@ -30,7 +30,7 @@ describe('RepoTabs', () => {
wrapper
.
destroy
();
});
it
(
'
renders a list of tabs
'
,
done
=>
{
it
(
'
renders a list of tabs
'
,
(
done
)
=>
{
store
.
state
.
openFiles
[
0
].
active
=
true
;
wrapper
.
vm
.
$nextTick
(()
=>
{
...
...
spec/frontend/ide/components/resizable_panel_spec.js
View file @
280a79c0
...
...
@@ -38,7 +38,7 @@ describe('~/ide/components/resizable_panel', () => {
};
const
findResizer
=
()
=>
wrapper
.
find
(
PanelResizer
);
const
findInlineStyle
=
()
=>
wrapper
.
element
.
style
.
cssText
;
const
createInlineStyle
=
width
=>
`width:
${
width
}
px;`
;
const
createInlineStyle
=
(
width
)
=>
`width:
${
width
}
px;`
;
describe
.
each
`
props | showResizer | resizerSide | expectedStyle
...
...
spec/frontend/ide/components/shared/tokened_input_spec.js
View file @
280a79c0
...
...
@@ -44,9 +44,9 @@ describe('IDE shared/TokenedInput', () => {
});
it
(
'
renders tokens
'
,
()
=>
{
const
renderedTokens
=
getTokenElements
(
vm
).
map
(
x
=>
x
.
textContent
.
trim
());
const
renderedTokens
=
getTokenElements
(
vm
).
map
(
(
x
)
=>
x
.
textContent
.
trim
());
expect
(
renderedTokens
).
toEqual
(
TEST_TOKENS
.
map
(
x
=>
x
.
label
));
expect
(
renderedTokens
).
toEqual
(
TEST_TOKENS
.
map
(
(
x
)
=>
x
.
label
));
});
it
(
'
renders input
'
,
()
=>
{
...
...
@@ -54,7 +54,7 @@ describe('IDE shared/TokenedInput', () => {
expect
(
vm
.
$refs
.
input
).
toHaveValue
(
TEST_VALUE
);
});
it
(
'
renders placeholder, when tokens are empty
'
,
done
=>
{
it
(
'
renders placeholder, when tokens are empty
'
,
(
done
)
=>
{
vm
.
tokens
=
[];
vm
.
$nextTick
()
...
...
spec/frontend/ide/components/terminal/session_spec.js
View file @
280a79c0
...
...
@@ -67,7 +67,7 @@ describe('IDE TerminalSession', () => {
});
});
[
STARTING
,
PENDING
,
RUNNING
].
forEach
(
status
=>
{
[
STARTING
,
PENDING
,
RUNNING
].
forEach
(
(
status
)
=>
{
it
(
`show stop button when status is
${
status
}
`
,
()
=>
{
state
.
session
=
{
status
};
factory
();
...
...
@@ -82,7 +82,7 @@ describe('IDE TerminalSession', () => {
});
});
[
STOPPING
,
STOPPED
].
forEach
(
status
=>
{
[
STOPPING
,
STOPPED
].
forEach
(
(
status
)
=>
{
it
(
`show stop button when status is
${
status
}
`
,
()
=>
{
state
.
session
=
{
status
};
factory
();
...
...
spec/frontend/ide/components/terminal/terminal_controls_spec.js
View file @
280a79c0
...
...
@@ -17,7 +17,7 @@ describe('IDE TerminalControls', () => {
it
(
'
shows an up and down scroll button
'
,
()
=>
{
factory
();
expect
(
buttons
.
wrappers
.
map
(
x
=>
x
.
props
())).
toEqual
([
expect
(
buttons
.
wrappers
.
map
(
(
x
)
=>
x
.
props
())).
toEqual
([
expect
.
objectContaining
({
direction
:
'
up
'
,
disabled
:
true
}),
expect
.
objectContaining
({
direction
:
'
down
'
,
disabled
:
true
}),
]);
...
...
spec/frontend/ide/components/terminal/terminal_spec.js
View file @
280a79c0
...
...
@@ -31,7 +31,7 @@ describe('IDE Terminal', () => {
let
wrapper
;
let
state
;
const
factory
=
propsData
=>
{
const
factory
=
(
propsData
)
=>
{
const
store
=
new
Vuex
.
Store
({
state
,
mutations
:
{
...
...
@@ -63,7 +63,7 @@ describe('IDE Terminal', () => {
});
describe
(
'
loading text
'
,
()
=>
{
[
STARTING
,
PENDING
].
forEach
(
status
=>
{
[
STARTING
,
PENDING
].
forEach
(
(
status
)
=>
{
it
(
`shows when starting (
${
status
}
)`
,
()
=>
{
factory
({
status
});
...
...
@@ -79,7 +79,7 @@ describe('IDE Terminal', () => {
expect
(
wrapper
.
find
(
'
.top-bar
'
).
text
()).
toBe
(
'
Stopping...
'
);
});
[
RUNNING
,
STOPPED
].
forEach
(
status
=>
{
[
RUNNING
,
STOPPED
].
forEach
(
(
status
)
=>
{
it
(
'
hides when not loading
'
,
()
=>
{
factory
({
status
});
...
...
spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js
View file @
280a79c0
...
...
@@ -26,7 +26,7 @@ describe('ide/components/terminal_sync/terminal_sync_status', () => {
namespaced
:
true
,
state
:
moduleState
,
mutations
:
{
[
START_LOADING
]:
state
=>
{
[
START_LOADING
]:
(
state
)
=>
{
state
.
isLoading
=
true
;
},
},
...
...
spec/frontend/ide/file_helpers.js
View file @
280a79c0
...
...
@@ -26,7 +26,7 @@ export const createMovedFile = (path, prevPath, content) =>
prevPath
,
});
export
const
createEntries
=
path
=>
export
const
createEntries
=
(
path
)
=>
path
.
split
(
'
/
'
).
reduce
((
acc
,
part
,
idx
,
parts
)
=>
{
const
parentPath
=
parts
.
slice
(
0
,
idx
).
join
(
'
/
'
);
const
fullPath
=
parentPath
?
`
${
parentPath
}
/
${
part
}
`
:
part
;
...
...
spec/frontend/ide/helpers.js
View file @
280a79c0
...
...
@@ -12,9 +12,9 @@ export const file = (name = 'name', id = name, type = '', parent = null) =>
parentPath
:
parent
?
parent
.
path
:
''
,
});
export
const
createEntriesFromPaths
=
paths
=>
export
const
createEntriesFromPaths
=
(
paths
)
=>
paths
.
map
(
path
=>
({
.
map
(
(
path
)
=>
({
name
:
pathUtils
.
basename
(
path
),
dir
:
pathUtils
.
dirname
(
path
),
ext
:
pathUtils
.
extname
(
path
),
...
...
@@ -30,7 +30,7 @@ export const createEntriesFromPaths = paths =>
};
},
{});
export
const
createTriggerChangeAction
=
payload
=>
({
export
const
createTriggerChangeAction
=
(
payload
)
=>
({
type
:
'
triggerFilesChange
'
,
...(
payload
?
{
payload
}
:
{}),
});
...
...
spec/frontend/ide/ide_router_extension_spec.js
View file @
280a79c0
...
...
@@ -4,7 +4,7 @@ import IdeRouter from '~/ide/ide_router_extension';
jest
.
mock
(
'
vue-router
'
);
describe
(
'
IDE overrides of VueRouter
'
,
()
=>
{
const
paths
=
branch
=>
[
const
paths
=
(
branch
)
=>
[
`
${
branch
}
`
,
`/
${
branch
}
`
,
`/
${
branch
}
/-/`
,
...
...
@@ -35,7 +35,7 @@ describe('IDE overrides of VueRouter', () => {
${
'
test-#-hash
'
}
|
${
'
test-%23-hash
'
}
${
'
test/hash#123
'
}
|
${
'
test/hash%23123
'
}
`
(
'
finds project path when route is $path
'
,
({
path
,
expected
})
=>
{
paths
(
path
).
forEach
(
route
=>
{
paths
(
path
).
forEach
(
(
route
)
=>
{
const
expectedPath
=
route
.
replace
(
path
,
expected
);
router
.
push
(
route
);
...
...
spec/frontend/ide/ide_router_spec.js
View file @
280a79c0
...
...
@@ -32,7 +32,7 @@ describe('IDE router', () => {
`/project/
${
PROJECT_NAMESPACE
}
/
${
PROJECT_NAME
}
/tree/blob`
,
`/project/
${
PROJECT_NAMESPACE
}
/
${
PROJECT_NAME
}
/edit`
,
`/project/
${
PROJECT_NAMESPACE
}
/
${
PROJECT_NAME
}
`
,
].
forEach
(
route
=>
{
].
forEach
(
(
route
)
=>
{
it
(
`finds project path when route is "
${
route
}
"`
,
()
=>
{
router
.
push
(
route
);
...
...
spec/frontend/ide/lib/common/model_spec.js
View file @
280a79c0
...
...
@@ -81,7 +81,7 @@ describe('Multi-file editor library model', () => {
});
describe
(
'
onChange
'
,
()
=>
{
it
(
'
calls callback on change
'
,
done
=>
{
it
(
'
calls callback on change
'
,
(
done
)
=>
{
const
spy
=
jest
.
fn
();
model
.
onChange
(
spy
);
...
...
spec/frontend/ide/lib/create_diff_spec.js
View file @
280a79c0
...
...
@@ -145,12 +145,12 @@ new file mode 100644
--- /dev/null
+++ b/
${
PATH_LOREM
}
@@ -0,0 +1,
${
LINES
.
length
}
@@
${
LINES
.
map
(
line
=>
`+
${
line
}
`
).
join
(
'
\n
'
)}
${
LINES
.
map
(
(
line
)
=>
`+
${
line
}
`
).
join
(
'
\n
'
)}
diff --git "a/
${
PATH_IPSUM
}
" "b/
${
PATH_IPSUM
}
"
--- a/
${
PATH_IPSUM
}
+++ b/
${
PATH_IPSUM
}
@@ -1,
${
LINES
.
length
}
+1,1 @@
${
LINES
.
map
(
line
=>
`-
${
line
}
`
).
join
(
'
\n
'
)}
${
LINES
.
map
(
(
line
)
=>
`-
${
line
}
`
).
join
(
'
\n
'
)}
+That's all folks!
\\ No newline at end of file
`
;
...
...
@@ -167,10 +167,10 @@ ${LINES.map(line => `-${line}`).join('\n')}
const
deletedFiles
=
[
'
foo/bar/zed/test.md
'
,
'
foo/bar/zed/test2.md
'
];
const
entries
=
deletedFiles
.
reduce
((
acc
,
path
)
=>
Object
.
assign
(
acc
,
createEntries
(
path
)),
{});
const
allDeleted
=
[...
deletedFiles
,
'
foo/bar/zed
'
,
'
foo/bar
'
];
allDeleted
.
forEach
(
path
=>
{
allDeleted
.
forEach
(
(
path
)
=>
{
entries
[
path
].
deleted
=
true
;
});
const
changedFiles
=
deletedFiles
.
map
(
x
=>
entries
[
x
]);
const
changedFiles
=
deletedFiles
.
map
(
(
x
)
=>
entries
[
x
]);
const
result
=
createDiff
({
changedFiles
,
entries
});
...
...
spec/frontend/ide/lib/create_file_diff_spec.js
View file @
280a79c0
...
...
@@ -51,7 +51,7 @@ describe('IDE lib/create_file_diff', () => {
const
expectedHead
=
`diff --git "a/
${
PATH
}
" "b/
${
PATH
}
"
new file mode 100644`
;
const
expectedChunkHead
=
lineCount
=>
`--- /dev/null
const
expectedChunkHead
=
(
lineCount
)
=>
`--- /dev/null
+++ b/
${
PATH
}
@@ -0,0 +1,
${
lineCount
}
@@`
;
...
...
@@ -86,7 +86,7 @@ ${expectedChunkHead(1)}
expect
(
result
).
toBe
(
`
${
expectedHead
}
${
expectedChunkHead
(
TEXT_LINE_COUNT
)}
${
mapLines
(
TEXT
,
line
=>
`+
${
line
}
`
)}
${
mapLines
(
TEXT
,
(
line
)
=>
`+
${
line
}
`
)}
`
);
});
});
...
...
@@ -95,7 +95,7 @@ ${mapLines(TEXT, line => `+${line}`)}
const
expectedHead
=
`diff --git "a/
${
PATH
}
" "b/
${
PATH
}
"
deleted file mode 100644`
;
const
expectedChunkHead
=
lineCount
=>
`--- a/
${
PATH
}
const
expectedChunkHead
=
(
lineCount
)
=>
`--- a/
${
PATH
}
+++ /dev/null
@@ -1,
${
lineCount
}
+0,0 @@`
;
...
...
@@ -111,7 +111,7 @@ deleted file mode 100644`;
expect
(
result
).
toBe
(
`
${
expectedHead
}
${
expectedChunkHead
(
TEXT_LINE_COUNT
)}
${
mapLines
(
TEXT
,
line
=>
`-
${
line
}
`
)}
${
mapLines
(
TEXT
,
(
line
)
=>
`-
${
line
}
`
)}
`
);
});
});
...
...
spec/frontend/ide/lib/diff/controller_spec.js
View file @
280a79c0
...
...
@@ -37,7 +37,7 @@ describe('Multi-file editor library dirty diff controller', () => {
});
describe
(
'
getDiffChangeType
'
,
()
=>
{
[
'
added
'
,
'
removed
'
,
'
modified
'
].
forEach
(
type
=>
{
[
'
added
'
,
'
removed
'
,
'
modified
'
].
forEach
(
(
type
)
=>
{
it
(
`returns
${
type
}
`
,
()
=>
{
const
change
=
{
[
type
]:
true
,
...
...
@@ -49,7 +49,7 @@ describe('Multi-file editor library dirty diff controller', () => {
});
describe
(
'
getDecorator
'
,
()
=>
{
[
'
added
'
,
'
removed
'
,
'
modified
'
].
forEach
(
type
=>
{
[
'
added
'
,
'
removed
'
,
'
modified
'
].
forEach
(
(
type
)
=>
{
it
(
`returns with linesDecorationsClassName for
${
type
}
`
,
()
=>
{
const
change
=
{
[
type
]:
true
,
...
...
spec/frontend/ide/lib/editor_spec.js
View file @
280a79c0
...
...
@@ -15,7 +15,7 @@ describe('Multi-file editor library', () => {
let
holder
;
let
store
;
const
setNodeOffsetWidth
=
val
=>
{
const
setNodeOffsetWidth
=
(
val
)
=>
{
Object
.
defineProperty
(
instance
.
instance
.
getDomNode
(),
'
offsetWidth
'
,
{
get
()
{
return
val
;
...
...
spec/frontend/ide/lib/editorconfig/parser_spec.js
View file @
280a79c0
...
...
@@ -2,14 +2,14 @@ import { getRulesWithTraversal } from '~/ide/lib/editorconfig/parser';
import
{
exampleConfigs
,
exampleFiles
}
from
'
./mock_data
'
;
describe
(
'
~/ide/lib/editorconfig/parser
'
,
()
=>
{
const
getExampleConfigContent
=
path
=>
Promise
.
resolve
(
exampleConfigs
.
find
(
x
=>
x
.
path
===
path
)?.
content
);
const
getExampleConfigContent
=
(
path
)
=>
Promise
.
resolve
(
exampleConfigs
.
find
(
(
x
)
=>
x
.
path
===
path
)?.
content
);
describe
(
'
getRulesWithTraversal
'
,
()
=>
{
it
.
each
(
exampleFiles
)(
'
traverses through all editorconfig files in parent directories (until root=true is hit) and finds rules for this file (case %#)
'
,
({
path
,
rules
})
=>
{
return
getRulesWithTraversal
(
path
,
getExampleConfigContent
).
then
(
result
=>
{
return
getRulesWithTraversal
(
path
,
getExampleConfigContent
).
then
(
(
result
)
=>
{
expect
(
result
).
toEqual
(
rules
);
});
},
...
...
spec/frontend/ide/lib/errors_spec.js
View file @
280a79c0
...
...
@@ -14,7 +14,7 @@ const CODEOWNERS_MESSAGE =
const
CHANGED_MESSAGE
=
'
Things changed since you started editing
'
;
describe
(
'
~/ide/lib/errors
'
,
()
=>
{
const
createResponseError
=
message
=>
({
const
createResponseError
=
(
message
)
=>
({
response
:
{
data
:
{
message
,
...
...
spec/frontend/ide/lib/files_spec.js
View file @
280a79c0
...
...
@@ -3,7 +3,7 @@ import { decorateData } from '~/ide/stores/utils';
const
TEST_BLOB_DATA
=
{
mimeType
:
'
test/mime
'
};
const
createEntries
=
paths
=>
{
const
createEntries
=
(
paths
)
=>
{
const
createEntry
=
(
acc
,
{
path
,
type
,
children
})
=>
{
const
{
name
,
parent
}
=
splitParent
(
path
);
...
...
@@ -15,7 +15,7 @@ const createEntries = paths => {
type
,
parentPath
:
parent
,
}),
tree
:
children
.
map
(
childName
=>
expect
.
objectContaining
({
name
:
childName
})),
tree
:
children
.
map
(
(
childName
)
=>
expect
.
objectContaining
({
name
:
childName
})),
...(
type
===
'
blob
'
?
TEST_BLOB_DATA
:
{}),
};
...
...
@@ -53,7 +53,7 @@ describe('IDE lib decorate files', () => {
const
entryKeys
=
Object
.
keys
(
entries
);
expect
(
entryKeys
).
toEqual
(
Object
.
keys
(
expectedEntries
));
entryKeys
.
forEach
(
key
=>
{
entryKeys
.
forEach
(
(
key
)
=>
{
expect
(
entries
[
key
]).
toEqual
(
expectedEntries
[
key
]);
});
...
...
spec/frontend/ide/lib/mirror_spec.js
View file @
280a79c0
...
...
@@ -72,7 +72,7 @@ describe('ide/lib/mirror', () => {
});
const
waitForConnection
=
(
delay
=
SERVICE_DELAY
)
=>
{
const
wait
=
new
Promise
(
resolve
=>
{
const
wait
=
new
Promise
(
(
resolve
)
=>
{
setTimeout
(
resolve
,
10
);
});
...
...
@@ -82,7 +82,7 @@ describe('ide/lib/mirror', () => {
};
const
connectPass
=
()
=>
waitForConnection
().
then
(()
=>
mockWebSocket
.
onopen
());
const
connectFail
=
()
=>
waitForConnection
().
then
(()
=>
mockWebSocket
.
onerror
());
const
sendResponse
=
msg
=>
{
const
sendResponse
=
(
msg
)
=>
{
mockWebSocket
.
onmessage
(
msg
);
};
...
...
spec/frontend/ide/services/index_spec.js
View file @
280a79c0
...
...
@@ -51,7 +51,7 @@ describe('IDE services', () => {
raw
:
'
raw content
'
,
};
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
raw
).
toBe
(
'
content
'
);
});
});
...
...
@@ -65,7 +65,7 @@ describe('IDE services', () => {
raw
:
'
raw content
'
,
};
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
raw
).
toBe
(
'
raw content
'
);
});
});
...
...
@@ -77,7 +77,7 @@ describe('IDE services', () => {
raw
:
'
raw content
'
,
};
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
raw
).
toBe
(
'
raw content
'
);
});
});
...
...
@@ -89,7 +89,7 @@ describe('IDE services', () => {
raw
:
''
,
};
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
raw
).
toBe
(
''
);
});
});
...
...
@@ -116,7 +116,7 @@ describe('IDE services', () => {
});
it
(
'
sends a request to file.rawPath
'
,
()
=>
{
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
file
.
rawPath
,
{
transformResponse
:
[
expect
.
any
(
Function
)],
});
...
...
@@ -127,7 +127,7 @@ describe('IDE services', () => {
it
(
'
returns arraybuffer for binary files
'
,
()
=>
{
file
.
binary
=
true
;
return
services
.
getRawFileData
(
file
).
then
(
raw
=>
{
return
services
.
getRawFileData
(
file
).
then
(
(
raw
)
=>
{
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
file
.
rawPath
,
{
transformResponse
:
[
expect
.
any
(
Function
)],
responseType
:
'
arraybuffer
'
,
...
...
@@ -161,7 +161,7 @@ describe('IDE services', () => {
it
(
'
gives back file.baseRaw for files with that property present
'
,
()
=>
{
file
.
baseRaw
=
TEST_FILE_CONTENTS
;
return
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
content
=>
{
return
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
(
content
)
=>
{
expect
(
content
).
toEqual
(
TEST_FILE_CONTENTS
);
});
});
...
...
@@ -170,7 +170,7 @@ describe('IDE services', () => {
file
.
tempFile
=
true
;
file
.
baseRaw
=
TEST_FILE_CONTENTS
;
return
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
content
=>
{
return
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
(
content
)
=>
{
expect
(
content
).
toEqual
(
TEST_FILE_CONTENTS
);
});
});
...
...
@@ -207,7 +207,7 @@ describe('IDE services', () => {
});
it
(
'
fetches file content
'
,
()
=>
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
content
=>
{
services
.
getBaseRawFileData
(
file
,
TEST_PROJECT_ID
,
TEST_COMMIT_SHA
).
then
(
(
content
)
=>
{
expect
(
content
).
toEqual
(
TEST_FILE_CONTENTS
);
}));
},
...
...
@@ -224,7 +224,7 @@ describe('IDE services', () => {
Api
.
project
.
mockReturnValue
(
Promise
.
resolve
({
data
:
{
...
projectData
}
}));
query
.
mockReturnValue
(
Promise
.
resolve
({
data
:
{
project
:
gqlProjectData
}
}));
return
services
.
getProjectData
(
TEST_NAMESPACE
,
TEST_PROJECT
).
then
(
response
=>
{
return
services
.
getProjectData
(
TEST_NAMESPACE
,
TEST_PROJECT
).
then
(
(
response
)
=>
{
expect
(
response
).
toEqual
({
data
:
{
...
projectData
,
...
gqlProjectData
}
});
expect
(
Api
.
project
).
toHaveBeenCalledWith
(
TEST_PROJECT_ID
);
expect
(
query
).
toHaveBeenCalledWith
({
...
...
spec/frontend/ide/stores/actions/file_spec.js
View file @
280a79c0
...
...
@@ -189,7 +189,7 @@ describe('IDE store file actions', () => {
});
describe
(
'
call to service
'
,
()
=>
{
const
callExpectation
=
serviceCalled
=>
{
const
callExpectation
=
(
serviceCalled
)
=>
{
store
.
dispatch
(
'
getFileData
'
,
{
path
:
localFile
.
path
});
if
(
serviceCalled
)
{
...
...
@@ -422,11 +422,11 @@ describe('IDE store file actions', () => {
loadingWhenGettingRawData
=
undefined
;
loadingWhenGettingBaseRawData
=
undefined
;
jest
.
spyOn
(
service
,
'
getRawFileData
'
).
mockImplementation
(
f
=>
{
jest
.
spyOn
(
service
,
'
getRawFileData
'
).
mockImplementation
(
(
f
)
=>
{
loadingWhenGettingRawData
=
f
.
loading
;
return
Promise
.
resolve
(
'
raw
'
);
});
jest
.
spyOn
(
service
,
'
getBaseRawFileData
'
).
mockImplementation
(
f
=>
{
jest
.
spyOn
(
service
,
'
getBaseRawFileData
'
).
mockImplementation
(
(
f
)
=>
{
loadingWhenGettingBaseRawData
=
f
.
loading
;
return
Promise
.
resolve
(
'
rawBase
'
);
});
...
...
@@ -743,7 +743,7 @@ describe('IDE store file actions', () => {
});
it
(
'
returns true when opened
'
,
()
=>
{
return
store
.
dispatch
(
'
openPendingTab
'
,
{
file
:
f
,
keyPrefix
:
'
pending
'
}).
then
(
added
=>
{
return
store
.
dispatch
(
'
openPendingTab
'
,
{
file
:
f
,
keyPrefix
:
'
pending
'
}).
then
(
(
added
)
=>
{
expect
(
added
).
toBe
(
true
);
});
});
...
...
@@ -755,7 +755,7 @@ describe('IDE store file actions', () => {
key
:
`pending-
${
f
.
key
}
`
,
});
return
store
.
dispatch
(
'
openPendingTab
'
,
{
file
:
f
,
keyPrefix
:
'
pending
'
}).
then
(
added
=>
{
return
store
.
dispatch
(
'
openPendingTab
'
,
{
file
:
f
,
keyPrefix
:
'
pending
'
}).
then
(
(
added
)
=>
{
expect
(
added
).
toBe
(
false
);
});
});
...
...
spec/frontend/ide/stores/actions/merge_request_spec.js
View file @
280a79c0
...
...
@@ -49,7 +49,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests/
).
reply
(
200
,
mockData
);
});
it
(
'
calls getProjectMergeRequests service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequests service method
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestsForBranch
'
,
{
projectId
:
TEST_PROJECT
,
branchId
:
'
bar
'
})
.
then
(()
=>
{
...
...
@@ -66,7 +66,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sets the "Merge Request" Object
'
,
done
=>
{
it
(
'
sets the "Merge Request" Object
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestsForBranch
'
,
{
projectId
:
TEST_PROJECT
,
branchId
:
'
bar
'
})
.
then
(()
=>
{
...
...
@@ -78,7 +78,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sets "Current Merge Request" object to the most recent MR
'
,
done
=>
{
it
(
'
sets "Current Merge Request" object to the most recent MR
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestsForBranch
'
,
{
projectId
:
TEST_PROJECT
,
branchId
:
'
bar
'
})
.
then
(()
=>
{
...
...
@@ -88,7 +88,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does nothing if user cannot read MRs
'
,
done
=>
{
it
(
'
does nothing if user cannot read MRs
'
,
(
done
)
=>
{
store
.
state
.
projects
[
TEST_PROJECT
].
userPermissions
[
PERMISSION_READ_MR
]
=
false
;
store
...
...
@@ -108,7 +108,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests/
).
reply
(
200
,
[]);
});
it
(
'
does not fail if there are no merge requests for current branch
'
,
done
=>
{
it
(
'
does not fail if there are no merge requests for current branch
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestsForBranch
'
,
{
projectId
:
TEST_PROJECT
,
branchId
:
'
foo
'
})
.
then
(()
=>
{
...
...
@@ -126,7 +126,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests/
).
networkError
();
});
it
(
'
flashes message, if error
'
,
done
=>
{
it
(
'
flashes message, if error
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestsForBranch
'
,
{
projectId
:
TEST_PROJECT
,
branchId
:
'
bar
'
})
.
catch
(()
=>
{
...
...
@@ -149,7 +149,7 @@ describe('IDE store merge request actions', () => {
.
reply
(
200
,
{
title
:
'
mergerequest
'
});
});
it
(
'
calls getProjectMergeRequestData service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestData service method
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestData
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -160,7 +160,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sets the Merge Request Object
'
,
done
=>
{
it
(
'
sets the Merge Request Object
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestData
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -180,7 +180,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1/
).
networkError
();
});
it
(
'
dispatches error action
'
,
done
=>
{
it
(
'
dispatches error action
'
,
(
done
)
=>
{
const
dispatch
=
jest
.
fn
();
getMergeRequestData
(
...
...
@@ -224,7 +224,7 @@ describe('IDE store merge request actions', () => {
.
reply
(
200
,
{
title
:
'
mergerequest
'
});
});
it
(
'
calls getProjectMergeRequestChanges service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestChanges service method
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestChanges
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -235,7 +235,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sets the Merge Request Changes Object
'
,
done
=>
{
it
(
'
sets the Merge Request Changes Object
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestChanges
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -253,7 +253,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
changes/
).
networkError
();
});
it
(
'
dispatches error action
'
,
done
=>
{
it
(
'
dispatches error action
'
,
(
done
)
=>
{
const
dispatch
=
jest
.
fn
();
getMergeRequestChanges
(
...
...
@@ -296,7 +296,7 @@ describe('IDE store merge request actions', () => {
jest
.
spyOn
(
service
,
'
getProjectMergeRequestVersions
'
);
});
it
(
'
calls getProjectMergeRequestVersions service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestVersions service method
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestVersions
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -307,7 +307,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sets the Merge Request Versions Object
'
,
done
=>
{
it
(
'
sets the Merge Request Versions Object
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getMergeRequestVersions
'
,
{
projectId
:
TEST_PROJECT
,
mergeRequestId
:
1
})
.
then
(()
=>
{
...
...
@@ -323,7 +323,7 @@ describe('IDE store merge request actions', () => {
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
versions/
).
networkError
();
});
it
(
'
dispatches error action
'
,
done
=>
{
it
(
'
dispatches error action
'
,
(
done
)
=>
{
const
dispatch
=
jest
.
fn
();
getMergeRequestVersions
(
...
...
@@ -422,7 +422,7 @@ describe('IDE store merge request actions', () => {
);
});
it
(
'
dispatches actions for merge request data
'
,
done
=>
{
it
(
'
dispatches actions for merge request data
'
,
(
done
)
=>
{
openMergeRequest
({
state
:
store
.
state
,
dispatch
:
store
.
dispatch
,
getters
:
mockGetters
},
mr
)
.
then
(()
=>
{
expect
(
store
.
dispatch
.
mock
.
calls
).
toEqual
([
...
...
@@ -451,7 +451,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
updates activity bar view and gets file data, if changes are found
'
,
done
=>
{
it
(
'
updates activity bar view and gets file data, if changes are found
'
,
(
done
)
=>
{
store
.
state
.
entries
.
foo
=
{
type
:
'
blob
'
,
};
...
...
@@ -490,7 +490,7 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
flashes message, if error
'
,
done
=>
{
it
(
'
flashes message, if error
'
,
(
done
)
=>
{
store
.
dispatch
.
mockRejectedValue
();
openMergeRequest
(
store
,
mr
)
...
...
spec/frontend/ide/stores/actions/project_spec.js
View file @
280a79c0
...
...
@@ -53,7 +53,7 @@ describe('IDE store project actions', () => {
});
});
it
(
'
calls the service
'
,
done
=>
{
it
(
'
calls the service
'
,
(
done
)
=>
{
store
.
dispatch
(
'
refreshLastCommitData
'
,
{
projectId
:
store
.
state
.
currentProjectId
,
...
...
@@ -67,7 +67,7 @@ describe('IDE store project actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
commits getBranchData
'
,
done
=>
{
it
(
'
commits getBranchData
'
,
(
done
)
=>
{
testAction
(
refreshLastCommitData
,
{
...
...
@@ -94,7 +94,7 @@ describe('IDE store project actions', () => {
});
describe
(
'
showBranchNotFoundError
'
,
()
=>
{
it
(
'
dispatches setErrorMessage
'
,
done
=>
{
it
(
'
dispatches setErrorMessage
'
,
(
done
)
=>
{
testAction
(
showBranchNotFoundError
,
'
master
'
,
...
...
@@ -123,7 +123,7 @@ describe('IDE store project actions', () => {
jest
.
spyOn
(
api
,
'
createBranch
'
).
mockResolvedValue
();
});
it
(
'
calls API
'
,
done
=>
{
it
(
'
calls API
'
,
(
done
)
=>
{
createNewBranchFromDefault
(
{
state
:
{
...
...
@@ -148,7 +148,7 @@ describe('IDE store project actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
clears error message
'
,
done
=>
{
it
(
'
clears error message
'
,
(
done
)
=>
{
const
dispatchSpy
=
jest
.
fn
().
mockName
(
'
dispatch
'
);
createNewBranchFromDefault
(
...
...
@@ -172,7 +172,7 @@ describe('IDE store project actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
reloads window
'
,
done
=>
{
it
(
'
reloads window
'
,
(
done
)
=>
{
createNewBranchFromDefault
(
{
state
:
{
...
...
@@ -196,7 +196,7 @@ describe('IDE store project actions', () => {
});
describe
(
'
loadEmptyBranch
'
,
()
=>
{
it
(
'
creates a blank tree and sets loading state to false
'
,
done
=>
{
it
(
'
creates a blank tree and sets loading state to false
'
,
(
done
)
=>
{
testAction
(
loadEmptyBranch
,
{
projectId
:
TEST_PROJECT_ID
,
branchId
:
'
master
'
},
...
...
@@ -213,7 +213,7 @@ describe('IDE store project actions', () => {
);
});
it
(
'
does nothing, if tree already exists
'
,
done
=>
{
it
(
'
does nothing, if tree already exists
'
,
(
done
)
=>
{
const
trees
=
{
[
`
${
TEST_PROJECT_ID
}
/master`
]:
[]
};
testAction
(
...
...
@@ -279,7 +279,7 @@ describe('IDE store project actions', () => {
const
branchId
=
'
123-lorem
'
;
const
ref
=
'
abcd2322
'
;
it
(
'
when empty repo, loads empty branch
'
,
done
=>
{
it
(
'
when empty repo, loads empty branch
'
,
(
done
)
=>
{
const
mockGetters
=
{
emptyRepo
:
true
};
testAction
(
...
...
@@ -292,13 +292,13 @@ describe('IDE store project actions', () => {
);
});
it
(
'
when branch already exists, does nothing
'
,
done
=>
{
it
(
'
when branch already exists, does nothing
'
,
(
done
)
=>
{
store
.
state
.
projects
[
projectId
].
branches
[
branchId
]
=
{};
testAction
(
loadBranch
,
{
projectId
,
branchId
},
store
.
state
,
[],
[],
done
);
});
it
(
'
fetches branch data
'
,
done
=>
{
it
(
'
fetches branch data
'
,
(
done
)
=>
{
const
mockGetters
=
{
findBranch
:
()
=>
({
commit
:
{
id
:
ref
}
})
};
jest
.
spyOn
(
store
,
'
dispatch
'
).
mockResolvedValue
();
...
...
@@ -317,7 +317,7 @@ describe('IDE store project actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
shows an error if branch can not be fetched
'
,
done
=>
{
it
(
'
shows an error if branch can not be fetched
'
,
(
done
)
=>
{
jest
.
spyOn
(
store
,
'
dispatch
'
).
mockReturnValue
(
Promise
.
reject
());
loadBranch
(
store
,
{
projectId
,
branchId
})
...
...
@@ -356,7 +356,7 @@ describe('IDE store project actions', () => {
jest
.
spyOn
(
store
,
'
dispatch
'
).
mockResolvedValue
();
});
it
(
'
dispatches branch actions
'
,
done
=>
{
it
(
'
dispatches branch actions
'
,
(
done
)
=>
{
openBranch
(
store
,
branch
)
.
then
(()
=>
{
expect
(
store
.
dispatch
.
mock
.
calls
).
toEqual
([
...
...
@@ -375,9 +375,9 @@ describe('IDE store project actions', () => {
jest
.
spyOn
(
store
,
'
dispatch
'
).
mockReturnValue
(
Promise
.
reject
());
});
it
(
'
dispatches correct branch actions
'
,
done
=>
{
it
(
'
dispatches correct branch actions
'
,
(
done
)
=>
{
openBranch
(
store
,
branch
)
.
then
(
val
=>
{
.
then
(
(
val
)
=>
{
expect
(
store
.
dispatch
.
mock
.
calls
).
toEqual
([
[
'
setCurrentBranchId
'
,
branchId
],
[
'
loadBranch
'
,
{
projectId
,
branchId
}],
...
...
spec/frontend/ide/stores/actions/tree_spec.js
View file @
280a79c0
...
...
@@ -68,7 +68,7 @@ describe('Multi-file store tree actions', () => {
);
});
it
(
'
adds data into tree
'
,
done
=>
{
it
(
'
adds data into tree
'
,
(
done
)
=>
{
store
.
dispatch
(
'
getFiles
'
,
basicCallParameters
)
.
then
(()
=>
{
...
...
@@ -93,7 +93,7 @@ describe('Multi-file store tree actions', () => {
});
describe
(
'
error
'
,
()
=>
{
it
(
'
dispatches error action
'
,
done
=>
{
it
(
'
dispatches error action
'
,
(
done
)
=>
{
const
dispatch
=
jest
.
fn
();
store
.
state
.
projects
=
{
...
...
@@ -148,7 +148,7 @@ describe('Multi-file store tree actions', () => {
store
.
state
.
entries
[
tree
.
path
]
=
tree
;
});
it
(
'
toggles the tree open
'
,
done
=>
{
it
(
'
toggles the tree open
'
,
(
done
)
=>
{
store
.
dispatch
(
'
toggleTreeOpen
'
,
tree
.
path
)
.
then
(()
=>
{
...
...
@@ -174,7 +174,7 @@ describe('Multi-file store tree actions', () => {
Object
.
assign
(
store
.
state
.
entries
,
createEntriesFromPaths
(
paths
));
});
it
(
'
opens the parents
'
,
done
=>
{
it
(
'
opens the parents
'
,
(
done
)
=>
{
testAction
(
showTreeEntry
,
'
grandparent/parent/child.txt
'
,
...
...
@@ -187,7 +187,7 @@ describe('Multi-file store tree actions', () => {
});
describe
(
'
setDirectoryData
'
,
()
=>
{
it
(
'
sets tree correctly if there are no opened files yet
'
,
done
=>
{
it
(
'
sets tree correctly if there are no opened files yet
'
,
(
done
)
=>
{
const
treeFile
=
file
({
name
:
'
README.md
'
});
store
.
state
.
trees
[
'
abcproject/master
'
]
=
{};
...
...
spec/frontend/ide/stores/actions_spec.js
View file @
280a79c0
...
...
@@ -42,7 +42,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
redirectToUrl
'
,
()
=>
{
it
(
'
calls visitUrl
'
,
done
=>
{
it
(
'
calls visitUrl
'
,
(
done
)
=>
{
store
.
dispatch
(
'
redirectToUrl
'
,
'
test
'
)
.
then
(()
=>
{
...
...
@@ -55,7 +55,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
setInitialData
'
,
()
=>
{
it
(
'
commits initial data
'
,
done
=>
{
it
(
'
commits initial data
'
,
(
done
)
=>
{
store
.
dispatch
(
'
setInitialData
'
,
{
canCommit
:
true
})
.
then
(()
=>
{
...
...
@@ -70,7 +70,7 @@ describe('Multi-file store actions', () => {
const
paths
=
[
'
to_discard
'
,
'
another_one_to_discard
'
];
beforeEach
(()
=>
{
paths
.
forEach
(
path
=>
{
paths
.
forEach
(
(
path
)
=>
{
const
f
=
file
(
path
);
f
.
changed
=
true
;
...
...
@@ -81,14 +81,14 @@ describe('Multi-file store actions', () => {
});
it
(
'
discards all changes in file
'
,
()
=>
{
const
expectedCalls
=
paths
.
map
(
path
=>
[
'
restoreOriginalFile
'
,
path
]);
const
expectedCalls
=
paths
.
map
(
(
path
)
=>
[
'
restoreOriginalFile
'
,
path
]);
discardAllChanges
(
store
);
expect
(
store
.
dispatch
.
mock
.
calls
).
toEqual
(
expect
.
arrayContaining
(
expectedCalls
));
});
it
(
'
removes all files from changedFiles state
'
,
done
=>
{
it
(
'
removes all files from changedFiles state
'
,
(
done
)
=>
{
store
.
dispatch
(
'
discardAllChanges
'
)
.
then
(()
=>
{
...
...
@@ -120,7 +120,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
tree
'
,
()
=>
{
it
(
'
creates temp tree
'
,
done
=>
{
it
(
'
creates temp tree
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
...
...
@@ -137,7 +137,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
creates new folder inside another tree
'
,
done
=>
{
it
(
'
creates new folder inside another tree
'
,
(
done
)
=>
{
const
tree
=
{
type
:
'
tree
'
,
name
:
'
testing
'
,
...
...
@@ -162,7 +162,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does not create new tree if already exists
'
,
done
=>
{
it
(
'
does not create new tree if already exists
'
,
(
done
)
=>
{
const
tree
=
{
type
:
'
tree
'
,
path
:
'
testing
'
,
...
...
@@ -188,7 +188,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
blob
'
,
()
=>
{
it
(
'
creates temp file
'
,
done
=>
{
it
(
'
creates temp file
'
,
(
done
)
=>
{
const
name
=
'
test
'
;
store
...
...
@@ -209,7 +209,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
adds tmp file to open files
'
,
done
=>
{
it
(
'
adds tmp file to open files
'
,
(
done
)
=>
{
const
name
=
'
test
'
;
store
...
...
@@ -228,7 +228,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
adds tmp file to staged files
'
,
done
=>
{
it
(
'
adds tmp file to staged files
'
,
(
done
)
=>
{
const
name
=
'
test
'
;
store
...
...
@@ -250,7 +250,7 @@ describe('Multi-file store actions', () => {
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
setFileActive
'
,
'
test
'
);
});
it
(
'
creates flash message if file already exists
'
,
done
=>
{
it
(
'
creates flash message if file already exists
'
,
(
done
)
=>
{
const
f
=
file
(
'
test
'
,
'
1
'
,
'
blob
'
);
store
.
state
.
trees
[
'
abcproject/mybranch
'
].
tree
=
[
f
];
store
.
state
.
entries
[
f
.
path
]
=
f
;
...
...
@@ -273,7 +273,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
scrollToTab
'
,
()
=>
{
it
(
'
focuses the current active element
'
,
done
=>
{
it
(
'
focuses the current active element
'
,
(
done
)
=>
{
document
.
body
.
innerHTML
+=
'
<div id="tabs"><div class="active"><div class="repo-tab"></div></div></div>
'
;
const
el
=
document
.
querySelector
(
'
.repo-tab
'
);
...
...
@@ -378,7 +378,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
updateViewer
'
,
()
=>
{
it
(
'
updates viewer state
'
,
done
=>
{
it
(
'
updates viewer state
'
,
(
done
)
=>
{
store
.
dispatch
(
'
updateViewer
'
,
'
diff
'
)
.
then
(()
=>
{
...
...
@@ -390,7 +390,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
updateActivityBarView
'
,
()
=>
{
it
(
'
commits UPDATE_ACTIVITY_BAR_VIEW
'
,
done
=>
{
it
(
'
commits UPDATE_ACTIVITY_BAR_VIEW
'
,
(
done
)
=>
{
testAction
(
updateActivityBarView
,
'
test
'
,
...
...
@@ -403,7 +403,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
setEmptyStateSvgs
'
,
()
=>
{
it
(
'
commits setEmptyStateSvgs
'
,
done
=>
{
it
(
'
commits setEmptyStateSvgs
'
,
(
done
)
=>
{
testAction
(
setEmptyStateSvgs
,
'
svg
'
,
...
...
@@ -416,7 +416,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
updateTempFlagForEntry
'
,
()
=>
{
it
(
'
commits UPDATE_TEMP_FLAG
'
,
done
=>
{
it
(
'
commits UPDATE_TEMP_FLAG
'
,
(
done
)
=>
{
const
f
=
{
...
file
(),
path
:
'
test
'
,
...
...
@@ -434,7 +434,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
commits UPDATE_TEMP_FLAG and dispatches for parent
'
,
done
=>
{
it
(
'
commits UPDATE_TEMP_FLAG and dispatches for parent
'
,
(
done
)
=>
{
const
parent
=
{
...
file
(),
path
:
'
testing
'
,
...
...
@@ -457,7 +457,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
does not dispatch for parent, if parent does not exist
'
,
done
=>
{
it
(
'
does not dispatch for parent, if parent does not exist
'
,
(
done
)
=>
{
const
f
=
{
...
file
(),
path
:
'
test
'
,
...
...
@@ -477,7 +477,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
setCurrentBranchId
'
,
()
=>
{
it
(
'
commits setCurrentBranchId
'
,
done
=>
{
it
(
'
commits setCurrentBranchId
'
,
(
done
)
=>
{
testAction
(
setCurrentBranchId
,
'
branchId
'
,
...
...
@@ -490,7 +490,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
toggleFileFinder
'
,
()
=>
{
it
(
'
commits TOGGLE_FILE_FINDER
'
,
done
=>
{
it
(
'
commits TOGGLE_FILE_FINDER
'
,
(
done
)
=>
{
testAction
(
toggleFileFinder
,
true
,
...
...
@@ -503,7 +503,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
setErrorMessage
'
,
()
=>
{
it
(
'
commis error messsage
'
,
done
=>
{
it
(
'
commis error messsage
'
,
(
done
)
=>
{
testAction
(
setErrorMessage
,
'
error
'
,
...
...
@@ -516,7 +516,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
deleteEntry
'
,
()
=>
{
it
(
'
commits entry deletion
'
,
done
=>
{
it
(
'
commits entry deletion
'
,
(
done
)
=>
{
store
.
state
.
entries
.
path
=
'
testing
'
;
testAction
(
...
...
@@ -529,7 +529,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
does not delete a folder after it is emptied
'
,
done
=>
{
it
(
'
does not delete a folder after it is emptied
'
,
(
done
)
=>
{
const
testFolder
=
{
type
:
'
tree
'
,
tree
:
[],
...
...
@@ -575,7 +575,7 @@ describe('Multi-file store actions', () => {
});
describe
(
'
and previous does not exist
'
,
()
=>
{
it
(
'
reverts the rename before deleting
'
,
done
=>
{
it
(
'
reverts the rename before deleting
'
,
(
done
)
=>
{
testAction
(
deleteEntry
,
testEntry
.
path
,
...
...
@@ -610,7 +610,7 @@ describe('Multi-file store actions', () => {
store
.
state
.
entries
[
oldEntry
.
path
]
=
oldEntry
;
});
it
(
'
does not revert rename before deleting
'
,
done
=>
{
it
(
'
does not revert rename before deleting
'
,
(
done
)
=>
{
testAction
(
deleteEntry
,
testEntry
.
path
,
...
...
@@ -621,7 +621,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
when previous is deleted, it reverts rename before deleting
'
,
done
=>
{
it
(
'
when previous is deleted, it reverts rename before deleting
'
,
(
done
)
=>
{
store
.
state
.
entries
[
testEntry
.
prevPath
].
deleted
=
true
;
testAction
(
...
...
@@ -656,7 +656,7 @@ describe('Multi-file store actions', () => {
jest
.
spyOn
(
eventHub
,
'
$emit
'
).
mockImplementation
();
});
it
(
'
does not purge model cache for temporary entries that got renamed
'
,
done
=>
{
it
(
'
does not purge model cache for temporary entries that got renamed
'
,
(
done
)
=>
{
Object
.
assign
(
store
.
state
.
entries
,
{
test
:
{
...
file
(
'
test
'
),
...
...
@@ -678,7 +678,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
purges model cache for renamed entry
'
,
done
=>
{
it
(
'
purges model cache for renamed entry
'
,
(
done
)
=>
{
Object
.
assign
(
store
.
state
.
entries
,
{
test
:
{
...
file
(
'
test
'
),
...
...
@@ -737,7 +737,7 @@ describe('Multi-file store actions', () => {
]);
});
it
(
'
if not changed, completely unstages and discards entry if renamed to original
'
,
done
=>
{
it
(
'
if not changed, completely unstages and discards entry if renamed to original
'
,
(
done
)
=>
{
testAction
(
renameEntry
,
{
path
:
'
renamed
'
,
name
:
'
orig
'
},
...
...
@@ -761,7 +761,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
if already in changed, does not add to change
'
,
done
=>
{
it
(
'
if already in changed, does not add to change
'
,
(
done
)
=>
{
store
.
state
.
changedFiles
.
push
(
renamedEntry
);
testAction
(
...
...
@@ -774,7 +774,7 @@ describe('Multi-file store actions', () => {
);
});
it
(
'
routes to the renamed file if the original file has been opened
'
,
done
=>
{
it
(
'
routes to the renamed file if the original file has been opened
'
,
(
done
)
=>
{
store
.
state
.
currentProjectId
=
'
test/test
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
...
...
@@ -815,7 +815,7 @@ describe('Multi-file store actions', () => {
});
});
it
(
'
updates entries in a folder correctly, when folder is renamed
'
,
done
=>
{
it
(
'
updates entries in a folder correctly, when folder is renamed
'
,
(
done
)
=>
{
store
.
dispatch
(
'
renameEntry
'
,
{
path
:
'
folder
'
,
...
...
@@ -833,7 +833,7 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
discards renaming of an entry if the root folder is renamed back to a previous name
'
,
done
=>
{
it
(
'
discards renaming of an entry if the root folder is renamed back to a previous name
'
,
(
done
)
=>
{
const
rootFolder
=
file
(
'
old-folder
'
,
'
old-folder
'
,
'
tree
'
);
const
testEntry
=
file
(
'
test
'
,
'
test
'
,
'
blob
'
,
rootFolder
);
...
...
@@ -925,7 +925,7 @@ describe('Multi-file store actions', () => {
});
});
it
(
'
creates new directory
'
,
done
=>
{
it
(
'
creates new directory
'
,
(
done
)
=>
{
expect
(
store
.
state
.
entries
[
newParentPath
]).
toBeUndefined
();
store
...
...
@@ -955,7 +955,7 @@ describe('Multi-file store actions', () => {
rootDir
.
tree
.
push
(
newDir
);
});
it
(
'
inserts in new directory
'
,
done
=>
{
it
(
'
inserts in new directory
'
,
(
done
)
=>
{
expect
(
newDir
.
tree
).
toEqual
([]);
store
...
...
@@ -971,11 +971,11 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
when new directory is deleted, it undeletes it
'
,
done
=>
{
it
(
'
when new directory is deleted, it undeletes it
'
,
(
done
)
=>
{
store
.
dispatch
(
'
deleteEntry
'
,
newParentPath
);
expect
(
store
.
state
.
entries
[
newParentPath
].
deleted
).
toBe
(
true
);
expect
(
rootDir
.
tree
.
some
(
x
=>
x
.
path
===
newParentPath
)).
toBe
(
false
);
expect
(
rootDir
.
tree
.
some
(
(
x
)
=>
x
.
path
===
newParentPath
)).
toBe
(
false
);
store
.
dispatch
(
'
renameEntry
'
,
{
...
...
@@ -985,7 +985,7 @@ describe('Multi-file store actions', () => {
})
.
then
(()
=>
{
expect
(
store
.
state
.
entries
[
newParentPath
].
deleted
).
toBe
(
false
);
expect
(
rootDir
.
tree
.
some
(
x
=>
x
.
path
===
newParentPath
)).
toBe
(
true
);
expect
(
rootDir
.
tree
.
some
(
(
x
)
=>
x
.
path
===
newParentPath
)).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -1029,12 +1029,12 @@ describe('Multi-file store actions', () => {
document
.
querySelector
(
'
.flash-container
'
).
remove
();
});
it
(
'
passes the error further unchanged without dispatching any action when response is 404
'
,
done
=>
{
it
(
'
passes the error further unchanged without dispatching any action when response is 404
'
,
(
done
)
=>
{
mock
.
onGet
(
/
(
.*
)
/
).
replyOnce
(
404
);
getBranchData
(...
callParams
)
.
then
(
done
.
fail
)
.
catch
(
e
=>
{
.
catch
(
(
e
)
=>
{
expect
(
dispatch
.
mock
.
calls
).
toHaveLength
(
0
);
expect
(
e
.
response
.
status
).
toEqual
(
404
);
expect
(
document
.
querySelector
(
'
.flash-alert
'
)).
toBeNull
();
...
...
@@ -1042,12 +1042,12 @@ describe('Multi-file store actions', () => {
});
});
it
(
'
does not pass the error further and flashes an alert if error is not 404
'
,
done
=>
{
it
(
'
does not pass the error further and flashes an alert if error is not 404
'
,
(
done
)
=>
{
mock
.
onGet
(
/
(
.*
)
/
).
replyOnce
(
418
);
getBranchData
(...
callParams
)
.
then
(
done
.
fail
)
.
catch
(
e
=>
{
.
catch
(
(
e
)
=>
{
expect
(
dispatch
.
mock
.
calls
).
toHaveLength
(
0
);
expect
(
e
.
response
).
toBeUndefined
();
expect
(
document
.
querySelector
(
'
.flash-alert
'
)).
not
.
toBeNull
();
...
...
spec/frontend/ide/stores/extend_spec.js
View file @
280a79c0
...
...
@@ -15,7 +15,7 @@ describe('ide/stores/extend', () => {
store
=
{};
el
=
{};
[
terminalPlugin
,
terminalSyncPlugin
].
forEach
(
x
=>
{
[
terminalPlugin
,
terminalSyncPlugin
].
forEach
(
(
x
)
=>
{
const
plugin
=
jest
.
fn
();
x
.
mockImplementation
(()
=>
plugin
);
...
...
@@ -28,7 +28,7 @@ describe('ide/stores/extend', () => {
terminalSyncPlugin
.
mockClear
();
});
const
withGonFeatures
=
features
=>
{
const
withGonFeatures
=
(
features
)
=>
{
global
.
gon
=
{
...
global
.
gon
,
features
};
};
...
...
spec/frontend/ide/stores/getters_spec.js
View file @
280a79c0
...
...
@@ -407,7 +407,7 @@ describe('IDE store getters', () => {
${
'
canCreateMergeRequests
'
}
|
${
'
createMergeRequestIn
'
}
${
'
canPushCode
'
}
|
${
'
pushCode
'
}
`
(
'
$getterName
'
,
({
getterName
,
permissionKey
})
=>
{
it
.
each
([
true
,
false
])(
'
finds permission for current project (%s)
'
,
val
=>
{
it
.
each
([
true
,
false
])(
'
finds permission for current project (%s)
'
,
(
val
)
=>
{
localState
.
projects
[
TEST_PROJECT_ID
]
=
{
userPermissions
:
{
[
permissionKey
]:
val
,
...
...
spec/frontend/ide/stores/integration_spec.js
View file @
280a79c0
...
...
@@ -84,7 +84,7 @@ describe('IDE store integration', () => {
store
.
dispatch
(
'
commit/updateFilesAfterCommit
'
,
{
data
:
{}
});
expect
(
store
.
state
.
entries
[
TEST_PATH
]).
toEqual
(
expected
);
expect
(
store
.
state
.
entries
[
TEST_PATH_DIR
].
tree
.
find
(
x
=>
x
.
path
===
TEST_PATH
)).
toEqual
(
expect
(
store
.
state
.
entries
[
TEST_PATH_DIR
].
tree
.
find
(
(
x
)
=>
x
.
path
===
TEST_PATH
)).
toEqual
(
expected
,
);
});
...
...
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