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
049d9b7c
Commit
049d9b7c
authored
May 07, 2020
by
Himanshu Kapoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate some IDE component specs to Jest
Migrate spec/javascripts/ide/components from Jasmine to Jest
parent
bc567629
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
45 deletions
+42
-45
spec/frontend/ide/components/commit_sidebar/radio_group_spec.js
...rontend/ide/components/commit_sidebar/radio_group_spec.js
+4
-9
spec/frontend/ide/components/file_row_extra_spec.js
spec/frontend/ide/components/file_row_extra_spec.js
+4
-4
spec/frontend/ide/components/ide_review_spec.js
spec/frontend/ide/components/ide_review_spec.js
+14
-10
spec/frontend/ide/components/ide_status_bar_spec.js
spec/frontend/ide/components/ide_status_bar_spec.js
+11
-13
spec/frontend/ide/components/merge_requests/item_spec.js
spec/frontend/ide/components/merge_requests/item_spec.js
+1
-1
spec/frontend/ide/components/new_dropdown/upload_spec.js
spec/frontend/ide/components/new_dropdown/upload_spec.js
+8
-8
No files found.
spec/
javascripts
/ide/components/commit_sidebar/radio_group_spec.js
→
spec/
frontend
/ide/components/commit_sidebar/radio_group_spec.js
View file @
049d9b7c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
resetStore
}
from
'
spec
/ide/helpers
'
;
import
{
resetStore
}
from
'
jest
/ide/helpers
'
;
import
store
from
'
~/ide/stores
'
;
import
store
from
'
~/ide/stores
'
;
import
radioGroup
from
'
~/ide/components/commit_sidebar/radio_group.vue
'
;
import
radioGroup
from
'
~/ide/components/commit_sidebar/radio_group.vue
'
;
...
@@ -41,13 +41,8 @@ describe('IDE commit sidebar radio group', () => {
...
@@ -41,13 +41,8 @@ describe('IDE commit sidebar radio group', () => {
radioGroup
,
radioGroup
,
},
},
store
,
store
,
template
:
`
render
:
createElement
=>
<radio-group
createElement
(
'
radio-group
'
,
{
props
:
{
value
:
'
1
'
}
},
'
Testing slot
'
),
value="1"
>
Testing slot
</radio-group>
`
,
});
});
vm
.
$mount
();
vm
.
$mount
();
...
...
spec/
javascripts
/ide/components/file_row_extra_spec.js
→
spec/
frontend
/ide/components/file_row_extra_spec.js
View file @
049d9b7c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
{
createComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
FileRowExtra
from
'
~/ide/components/file_row_extra.vue
'
;
import
FileRowExtra
from
'
~/ide/components/file_row_extra.vue
'
;
import
{
file
,
resetStore
}
from
'
../helpers
'
;
import
{
file
,
resetStore
}
from
'
../helpers
'
;
...
@@ -23,9 +23,9 @@ describe('IDE extra file row component', () => {
...
@@ -23,9 +23,9 @@ describe('IDE extra file row component', () => {
dropdownOpen
:
false
,
dropdownOpen
:
false
,
});
});
spyOnProperty
(
vm
,
'
getUnstagedFilesCountForPath
'
).
and
.
r
eturnValue
(()
=>
unstagedFilesCount
);
jest
.
spyOn
(
vm
,
'
getUnstagedFilesCountForPath
'
,
'
get
'
).
mockR
eturnValue
(()
=>
unstagedFilesCount
);
spyOnProperty
(
vm
,
'
getStagedFilesCountForPath
'
).
and
.
r
eturnValue
(()
=>
stagedFilesCount
);
jest
.
spyOn
(
vm
,
'
getStagedFilesCountForPath
'
,
'
get
'
).
mockR
eturnValue
(()
=>
stagedFilesCount
);
spyOnProperty
(
vm
,
'
getChangesInFolder
'
).
and
.
r
eturnValue
(()
=>
changesCount
);
jest
.
spyOn
(
vm
,
'
getChangesInFolder
'
,
'
get
'
).
mockR
eturnValue
(()
=>
changesCount
);
vm
.
$mount
();
vm
.
$mount
();
});
});
...
...
spec/
javascripts
/ide/components/ide_review_spec.js
→
spec/
frontend
/ide/components/ide_review_spec.js
View file @
049d9b7c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
IdeReview
from
'
~/ide/components/ide_review.vue
'
;
import
IdeReview
from
'
~/ide/components/ide_review.vue
'
;
import
store
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
trimText
}
from
'
../../helpers/text_helper
'
;
import
{
trimText
}
from
'
../../helpers/text_helper
'
;
import
{
resetStore
,
file
}
from
'
../helpers
'
;
import
{
resetStore
,
file
}
from
'
../helpers
'
;
...
@@ -9,8 +9,10 @@ import { projectData } from '../mock_data';
...
@@ -9,8 +9,10 @@ import { projectData } from '../mock_data';
describe
(
'
IDE review mode
'
,
()
=>
{
describe
(
'
IDE review mode
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
IdeReview
);
const
Component
=
Vue
.
extend
(
IdeReview
);
let
vm
;
let
vm
;
let
store
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
=
createStore
();
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
.
abcproject
=
Object
.
assign
({},
projectData
);
store
.
state
.
projects
.
abcproject
=
Object
.
assign
({},
projectData
);
...
@@ -33,14 +35,14 @@ describe('IDE review mode', () => {
...
@@ -33,14 +35,14 @@ describe('IDE review mode', () => {
});
});
describe
(
'
merge request
'
,
()
=>
{
describe
(
'
merge request
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
()
=>
{
store
.
state
.
currentMergeRequestId
=
'
1
'
;
store
.
state
.
currentMergeRequestId
=
'
1
'
;
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
iid
:
123
,
iid
:
123
,
web_url
:
'
testing123
'
,
web_url
:
'
testing123
'
,
};
};
vm
.
$nextTick
(
done
);
return
vm
.
$nextTick
(
);
});
});
it
(
'
renders edit dropdown
'
,
()
=>
{
it
(
'
renders edit dropdown
'
,
()
=>
{
...
@@ -48,21 +50,23 @@ describe('IDE review mode', () => {
...
@@ -48,21 +50,23 @@ describe('IDE review mode', () => {
});
});
it
(
'
renders merge request link & IID
'
,
()
=>
{
it
(
'
renders merge request link & IID
'
,
()
=>
{
const
link
=
vm
.
$el
.
querySelector
(
'
.ide-review-sub-header
'
)
;
store
.
state
.
viewer
=
'
mrdiff
'
;
expect
(
link
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toBe
(
'
testing123
'
);
return
vm
.
$nextTick
(()
=>
{
expect
(
trimText
(
link
.
textContent
)).
toBe
(
'
Merge request (!123)
'
);
const
link
=
vm
.
$el
.
querySelector
(
'
.ide-review-sub-header
'
);
expect
(
link
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toBe
(
'
testing123
'
);
expect
(
trimText
(
link
.
textContent
)).
toBe
(
'
Merge request (!123)
'
);
});
});
});
it
(
'
changes text to latest changes when viewer is not mrdiff
'
,
done
=>
{
it
(
'
changes text to latest changes when viewer is not mrdiff
'
,
()
=>
{
store
.
state
.
viewer
=
'
diff
'
;
store
.
state
.
viewer
=
'
diff
'
;
vm
.
$nextTick
(()
=>
{
return
vm
.
$nextTick
(()
=>
{
expect
(
trimText
(
vm
.
$el
.
querySelector
(
'
.ide-review-sub-header
'
).
textContent
)).
toBe
(
expect
(
trimText
(
vm
.
$el
.
querySelector
(
'
.ide-review-sub-header
'
).
textContent
)).
toBe
(
'
Latest changes
'
,
'
Latest changes
'
,
);
);
done
();
});
});
});
});
});
});
...
...
spec/
javascripts
/ide/components/ide_status_bar_spec.js
→
spec/
frontend
/ide/components/ide_status_bar_spec.js
View file @
049d9b7c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
{
createComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
TEST_HOST
}
from
'
spec
/test_constants
'
;
import
{
TEST_HOST
}
from
'
../../helpers
/test_constants
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
IdeStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
import
IdeStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
import
{
rightSidebarViews
}
from
'
~/ide/constants
'
;
import
{
rightSidebarViews
}
from
'
~/ide/constants
'
;
...
@@ -45,26 +45,24 @@ describe('ideStatusBar', () => {
...
@@ -45,26 +45,24 @@ describe('ideStatusBar', () => {
});
});
describe
(
'
commitAgeUpdate
'
,
()
=>
{
describe
(
'
commitAgeUpdate
'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(()
=>
{
jasmine
.
clock
().
install
();
jest
.
spyOn
(
vm
,
'
commitAgeUpdate
'
).
mockImplementation
(()
=>
{});
spyOn
(
vm
,
'
commitAgeUpdate
'
).
and
.
callFake
(()
=>
{});
vm
.
startTimer
();
});
});
afterEach
(
function
()
{
afterEach
(
()
=>
{
j
asmine
.
clock
().
uninstall
();
j
est
.
clearAllTimers
();
});
});
it
(
'
gets called every second
'
,
()
=>
{
it
(
'
gets called every second
'
,
()
=>
{
expect
(
vm
.
commitAgeUpdate
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
commitAgeUpdate
).
not
.
toHaveBeenCalled
();
j
asmine
.
clock
().
tick
(
11
00
);
j
est
.
advanceTimersByTime
(
10
00
);
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()
).
toEqual
(
1
);
expect
(
vm
.
commitAgeUpdate
.
mock
.
calls
.
length
).
toEqual
(
1
);
j
asmine
.
clock
().
tick
(
1000
);
j
est
.
advanceTimersByTime
(
1000
);
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()
).
toEqual
(
2
);
expect
(
vm
.
commitAgeUpdate
.
mock
.
calls
.
length
).
toEqual
(
2
);
});
});
});
});
...
@@ -76,7 +74,7 @@ describe('ideStatusBar', () => {
...
@@ -76,7 +74,7 @@ describe('ideStatusBar', () => {
describe
(
'
pipeline status
'
,
()
=>
{
describe
(
'
pipeline status
'
,
()
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
done
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
done
=>
{
spyOn
(
vm
,
'
openRightPane
'
);
jest
.
spyOn
(
vm
,
'
openRightPane
'
).
mockImplementation
(()
=>
{}
);
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
details
:
{
details
:
{
status
:
{
status
:
{
...
...
spec/
javascripts
/ide/components/merge_requests/item_spec.js
→
spec/
frontend
/ide/components/merge_requests/item_spec.js
View file @
049d9b7c
...
@@ -33,7 +33,7 @@ describe('IDE merge request item', () => {
...
@@ -33,7 +33,7 @@ describe('IDE merge request item', () => {
`/project/
${
vm
.
item
.
projectPathWithNamespace
}
/merge_requests/
${
vm
.
item
.
iid
}
`
,
`/project/
${
vm
.
item
.
projectPathWithNamespace
}
/merge_requests/
${
vm
.
item
.
iid
}
`
,
).
href
;
).
href
;
expect
(
vm
.
$el
).
toMatch
(
'
a
'
);
expect
(
vm
.
$el
.
tagName
.
toLowerCase
()).
toBe
(
'
a
'
);
expect
(
vm
.
$el
).
toHaveAttr
(
'
href
'
,
expectedHref
);
expect
(
vm
.
$el
).
toHaveAttr
(
'
href
'
,
expectedHref
);
});
});
...
...
spec/
javascripts
/ide/components/new_dropdown/upload_spec.js
→
spec/
frontend
/ide/components/new_dropdown/upload_spec.js
View file @
049d9b7c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
createComponent
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
createComponent
from
'
helpers/vue_mount_component_helper
'
;
import
upload
from
'
~/ide/components/new_dropdown/upload.vue
'
;
import
upload
from
'
~/ide/components/new_dropdown/upload.vue
'
;
describe
(
'
new dropdown upload
'
,
()
=>
{
describe
(
'
new dropdown upload
'
,
()
=>
{
...
@@ -14,7 +14,7 @@ describe('new dropdown upload', () => {
...
@@ -14,7 +14,7 @@ describe('new dropdown upload', () => {
vm
.
entryName
=
'
testing
'
;
vm
.
entryName
=
'
testing
'
;
spyOn
(
vm
,
'
$emit
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
vm
,
'
$emit
'
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -25,22 +25,22 @@ describe('new dropdown upload', () => {
...
@@ -25,22 +25,22 @@ describe('new dropdown upload', () => {
it
(
'
calls for each file
'
,
()
=>
{
it
(
'
calls for each file
'
,
()
=>
{
const
files
=
[
'
test
'
,
'
test2
'
,
'
test3
'
];
const
files
=
[
'
test
'
,
'
test2
'
,
'
test3
'
];
spyOn
(
vm
,
'
readFile
'
);
jest
.
spyOn
(
vm
,
'
readFile
'
).
mockImplementation
(()
=>
{}
);
spyOnProperty
(
vm
.
$refs
.
fileUpload
,
'
files
'
).
and
.
r
eturnValue
(
files
);
jest
.
spyOn
(
vm
.
$refs
.
fileUpload
,
'
files
'
,
'
get
'
).
mockR
eturnValue
(
files
);
vm
.
openFile
();
vm
.
openFile
();
expect
(
vm
.
readFile
.
calls
.
count
()
).
toBe
(
3
);
expect
(
vm
.
readFile
.
mock
.
calls
.
length
).
toBe
(
3
);
files
.
forEach
((
file
,
i
)
=>
{
files
.
forEach
((
file
,
i
)
=>
{
expect
(
vm
.
readFile
.
calls
.
argsFor
(
i
)
).
toEqual
([
file
]);
expect
(
vm
.
readFile
.
mock
.
calls
[
i
]
).
toEqual
([
file
]);
});
});
});
});
});
});
describe
(
'
readFile
'
,
()
=>
{
describe
(
'
readFile
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
FileReader
.
prototype
,
'
readAsDataURL
'
);
jest
.
spyOn
(
FileReader
.
prototype
,
'
readAsDataURL
'
).
mockImplementation
(()
=>
{}
);
});
});
it
(
'
calls readAsDataURL for all files
'
,
()
=>
{
it
(
'
calls readAsDataURL for all files
'
,
()
=>
{
...
@@ -69,7 +69,7 @@ describe('new dropdown upload', () => {
...
@@ -69,7 +69,7 @@ describe('new dropdown upload', () => {
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
FileReader
.
prototype
,
'
readAsText
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
FileReader
.
prototype
,
'
readAsText
'
);
});
});
it
(
'
calls readAsText and creates file in plain text (without encoding) if the file content is plain text
'
,
done
=>
{
it
(
'
calls readAsText and creates file in plain text (without encoding) if the file content is plain text
'
,
done
=>
{
...
...
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