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
89781e30
Commit
89781e30
authored
May 09, 2020
by
Himanshu Kapoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate batch_comments specs to Jest
Migrate most of ee/spec/javascrpts/batch_comments specs to Jest
parent
1f2ef687
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
69 additions
and
61 deletions
+69
-61
ee/spec/frontend/batch_comments/components/diff_file_drafts_spec.js
...ontend/batch_comments/components/diff_file_drafts_spec.js
+0
-0
ee/spec/frontend/batch_comments/components/draft_note_spec.js
...pec/frontend/batch_comments/components/draft_note_spec.js
+2
-2
ee/spec/frontend/batch_comments/components/drafts_count_spec.js
...c/frontend/batch_comments/components/drafts_count_spec.js
+1
-1
ee/spec/frontend/batch_comments/components/preview_item_spec.js
...c/frontend/batch_comments/components/preview_item_spec.js
+2
-2
ee/spec/frontend/batch_comments/components/publish_button_spec.js
...frontend/batch_comments/components/publish_button_spec.js
+2
-2
ee/spec/frontend/batch_comments/components/publish_dropdown_spec.js
...ontend/batch_comments/components/publish_dropdown_spec.js
+5
-5
ee/spec/frontend/batch_comments/mock_data.js
ee/spec/frontend/batch_comments/mock_data.js
+27
-0
ee/spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js
...ch_comments/stores/modules/batch_comments/actions_spec.js
+25
-25
ee/spec/javascripts/batch_comments/mock_data.js
ee/spec/javascripts/batch_comments/mock_data.js
+5
-24
No files found.
ee/spec/
javascripts
/batch_comments/components/diff_file_drafts_spec.js
→
ee/spec/
frontend
/batch_comments/components/diff_file_drafts_spec.js
View file @
89781e30
File moved
ee/spec/
javascripts
/batch_comments/components/draft_note_spec.js
→
ee/spec/
frontend
/batch_comments/components/draft_note_spec.js
View file @
89781e30
...
...
@@ -22,7 +22,7 @@ describe('Batch comments draft note component', () => {
localVue
,
});
spyOn
(
wrapper
.
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
jest
.
spyOn
(
wrapper
.
vm
.
$store
,
'
dispatch
'
).
mockImplementation
();
});
afterEach
(()
=>
{
...
...
@@ -91,7 +91,7 @@ describe('Batch comments draft note component', () => {
describe
(
'
deleteDraft
'
,
()
=>
{
it
(
'
dispatches deleteDraft
'
,
()
=>
{
spyOn
(
window
,
'
confirm
'
).
and
.
callFake
(()
=>
true
);
jest
.
spyOn
(
window
,
'
confirm
'
).
mockImplementation
(()
=>
true
);
const
note
=
wrapper
.
find
(
NoteableNote
);
...
...
ee/spec/
javascripts
/batch_comments/components/drafts_count_spec.js
→
ee/spec/
frontend
/batch_comments/components/drafts_count_spec.js
View file @
89781e30
import
Vue
from
'
vue
'
;
import
DraftsCount
from
'
ee/batch_comments/components/drafts_count.vue
'
;
import
{
mountComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createStore
}
from
'
ee/batch_comments/stores
'
;
describe
(
'
Batch comments drafts count component
'
,
()
=>
{
...
...
ee/spec/
javascripts
/batch_comments/components/preview_item_spec.js
→
ee/spec/
frontend
/batch_comments/components/preview_item_spec.js
View file @
89781e30
import
Vue
from
'
vue
'
;
import
PreviewItem
from
'
ee/batch_comments/components/preview_item.vue
'
;
import
{
mountComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createStore
}
from
'
ee/batch_comments/stores
'
;
import
diffsModule
from
'
~/diffs/store/modules
'
;
import
notesModule
from
'
~/notes/stores/modules
'
;
...
...
@@ -52,7 +52,7 @@ describe('Batch comments draft preview item component', () => {
it
(
'
scrolls to draft on click
'
,
()
=>
{
createComponent
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
jest
.
spyOn
(
vm
.
$store
,
'
dispatch
'
).
mockImplementation
();
vm
.
$el
.
click
();
...
...
ee/spec/
javascripts
/batch_comments/components/publish_button_spec.js
→
ee/spec/
frontend
/batch_comments/components/publish_button_spec.js
View file @
89781e30
import
Vue
from
'
vue
'
;
import
PublishButton
from
'
ee/batch_comments/components/publish_button.vue
'
;
import
{
mountComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createStore
}
from
'
ee/batch_comments/stores
'
;
describe
(
'
Batch comments publish button component
'
,
()
=>
{
...
...
@@ -16,7 +16,7 @@ describe('Batch comments publish button component', () => {
vm
=
mountComponentWithStore
(
Component
,
{
store
,
props
:
{
shouldPublish
:
true
}
});
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
jest
.
spyOn
(
vm
.
$store
,
'
dispatch
'
).
mockImplementation
();
});
afterEach
(()
=>
{
...
...
ee/spec/
javascripts
/batch_comments/components/publish_dropdown_spec.js
→
ee/spec/
frontend
/batch_comments/components/publish_dropdown_spec.js
View file @
89781e30
import
Vue
from
'
vue
'
;
import
PreviewDropdown
from
'
ee/batch_comments/components/preview_dropdown.vue
'
;
import
{
mountComponentWithStore
}
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createStore
}
from
'
ee/mr_notes/stores
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
{
createDraft
}
from
'
../mock_data
'
;
...
...
@@ -29,16 +29,16 @@ describe('Batch comments publish dropdown component', () => {
it
(
'
toggles dropdown when clicking button
'
,
done
=>
{
createComponent
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
vm
.
$store
,
'
dispatch
'
);
vm
.
$el
.
querySelector
(
'
.review-preview-dropdown-toggle
'
).
click
();
expect
(
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
batchComments/toggleReviewDropdown
'
,
jasmine
.
anything
(),
expect
.
anything
(),
);
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
vm
.
$el
.
classList
).
toContain
(
'
show
'
);
done
();
...
...
@@ -50,7 +50,7 @@ describe('Batch comments publish dropdown component', () => {
vm
.
$store
.
state
.
batchComments
.
showPreviewDropdown
=
true
;
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
jest
.
spyOn
(
vm
.
$store
,
'
dispatch
'
).
mockImplementation
();
document
.
body
.
click
();
...
...
ee/spec/frontend/batch_comments/mock_data.js
0 → 100644
View file @
89781e30
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
export
const
createDraft
=
()
=>
({
author
:
{
id
:
1
,
name
:
'
Test
'
,
username
:
'
test
'
,
state
:
'
active
'
,
avatar_url
:
TEST_HOST
,
},
current_user
:
{
can_edit
:
true
,
can_award_emoji
:
false
,
can_resolve
:
false
},
discussion_id
:
null
,
file_hash
:
null
,
file_path
:
null
,
id
:
1
,
line_code
:
null
,
merge_request_id
:
1
,
note
:
'
a
'
,
note_html
:
'
<p>Test</p>
'
,
noteable_type
:
'
MergeRequest
'
,
references
:
{
users
:
[],
commands
:
''
},
resolve_discussion
:
false
,
isDraft
:
true
,
position
:
null
,
});
export
default
()
=>
{};
ee/spec/
javascripts
/batch_comments/stores/modules/batch_comments/actions_spec.js
→
ee/spec/
frontend
/batch_comments/stores/modules/batch_comments/actions_spec.js
View file @
89781e30
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
spec/
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
*
as
actions
from
'
ee/batch_comments/stores/modules/batch_comments/actions
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
...
@@ -31,7 +31,7 @@ describe('Batch comments store actions', () => {
describe
(
'
saveDraft
'
,
()
=>
{
it
(
'
dispatches saveNote on root
'
,
()
=>
{
const
dispatch
=
j
asmine
.
createSpy
();
const
dispatch
=
j
est
.
fn
();
actions
.
saveDraft
({
dispatch
},
{
id
:
1
});
...
...
@@ -109,7 +109,7 @@ describe('Batch comments store actions', () => {
});
it
(
'
commits DELETE_DRAFT if no errors returned
'
,
done
=>
{
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
const
context
=
{
getters
,
commit
,
...
...
@@ -127,7 +127,7 @@ describe('Batch comments store actions', () => {
});
it
(
'
does not commit DELETE_DRAFT if errors returned
'
,
done
=>
{
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
const
context
=
{
getters
,
commit
,
...
...
@@ -156,7 +156,7 @@ describe('Batch comments store actions', () => {
});
it
(
'
commits SET_BATCH_COMMENTS_DRAFTS with returned data
'
,
done
=>
{
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
const
context
=
{
getters
,
commit
,
...
...
@@ -181,8 +181,8 @@ describe('Batch comments store actions', () => {
let
rootGetters
;
beforeEach
(()
=>
{
dispatch
=
j
asmine
.
createSpy
(
'
dispatch
'
);
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
dispatch
=
j
est
.
fn
(
);
commit
=
j
est
.
fn
(
);
getters
=
{
getNotesData
:
{
draftsPublishPath
:
gl
.
TEST_HOST
,
discussionsPath
:
gl
.
TEST_HOST
},
};
...
...
@@ -195,10 +195,10 @@ describe('Batch comments store actions', () => {
actions
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
.
then
(()
=>
{
expect
(
commit
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
REQUEST_PUBLISH_REVIEW
'
]);
expect
(
commit
.
calls
.
argsFor
(
1
)
).
toEqual
([
'
RECEIVE_PUBLISH_REVIEW_SUCCESS
'
]);
expect
(
commit
.
mock
.
calls
[
0
]
).
toEqual
([
'
REQUEST_PUBLISH_REVIEW
'
]);
expect
(
commit
.
mock
.
calls
[
1
]
).
toEqual
([
'
RECEIVE_PUBLISH_REVIEW_SUCCESS
'
]);
expect
(
dispatch
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
updateDiscussionsAfterPublish
'
]);
expect
(
dispatch
.
mock
.
calls
[
0
]
).
toEqual
([
'
updateDiscussionsAfterPublish
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -210,8 +210,8 @@ describe('Batch comments store actions', () => {
actions
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
.
then
(()
=>
{
expect
(
commit
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
REQUEST_PUBLISH_REVIEW
'
]);
expect
(
commit
.
calls
.
argsFor
(
1
)
).
toEqual
([
'
RECEIVE_PUBLISH_REVIEW_ERROR
'
]);
expect
(
commit
.
mock
.
calls
[
0
]
).
toEqual
([
'
REQUEST_PUBLISH_REVIEW
'
]);
expect
(
commit
.
mock
.
calls
[
1
]
).
toEqual
([
'
RECEIVE_PUBLISH_REVIEW_ERROR
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -223,14 +223,14 @@ describe('Batch comments store actions', () => {
const
getters
=
{
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
};
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
mock
.
onAny
().
reply
(
200
);
actions
.
discardReview
({
getters
,
commit
})
.
then
(()
=>
{
expect
(
commit
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
REQUEST_DISCARD_REVIEW
'
]);
expect
(
commit
.
calls
.
argsFor
(
1
)
).
toEqual
([
'
RECEIVE_DISCARD_REVIEW_SUCCESS
'
]);
expect
(
commit
.
mock
.
calls
[
0
]
).
toEqual
([
'
REQUEST_DISCARD_REVIEW
'
]);
expect
(
commit
.
mock
.
calls
[
1
]
).
toEqual
([
'
RECEIVE_DISCARD_REVIEW_SUCCESS
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -240,14 +240,14 @@ describe('Batch comments store actions', () => {
const
getters
=
{
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
};
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
mock
.
onAny
().
reply
(
500
);
actions
.
discardReview
({
getters
,
commit
})
.
then
(()
=>
{
expect
(
commit
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
REQUEST_DISCARD_REVIEW
'
]);
expect
(
commit
.
calls
.
argsFor
(
1
)
).
toEqual
([
'
RECEIVE_DISCARD_REVIEW_ERROR
'
]);
expect
(
commit
.
mock
.
calls
[
0
]
).
toEqual
([
'
REQUEST_DISCARD_REVIEW
'
]);
expect
(
commit
.
mock
.
calls
[
1
]
).
toEqual
([
'
RECEIVE_DISCARD_REVIEW_ERROR
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -266,7 +266,7 @@ describe('Batch comments store actions', () => {
});
it
(
'
commits RECEIVE_DRAFT_UPDATE_SUCCESS with returned data
'
,
done
=>
{
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
const
context
=
{
getters
,
commit
,
...
...
@@ -284,12 +284,12 @@ describe('Batch comments store actions', () => {
});
it
(
'
calls passed callback
'
,
done
=>
{
const
commit
=
j
asmine
.
createSpy
(
'
commit
'
);
const
commit
=
j
est
.
fn
(
);
const
context
=
{
getters
,
commit
,
};
const
callback
=
j
asmine
.
createSpy
(
'
callback
'
);
const
callback
=
j
est
.
fn
(
);
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
...
...
@@ -383,12 +383,12 @@ describe('Batch comments store actions', () => {
beforeEach
(()
=>
{
window
.
mrTabs
=
{
currentAction
:
'
notes
'
,
tabShown
:
j
asmine
.
createSpy
(
'
tabShown
'
),
tabShown
:
j
est
.
fn
(
),
};
});
it
(
'
scrolls to draft item
'
,
()
=>
{
const
dispatch
=
j
asmine
.
createSpy
(
'
dispatch
'
);
const
dispatch
=
j
est
.
fn
(
);
const
rootGetters
=
{
getDiscussion
:
()
=>
({
id
:
'
1
'
,
...
...
@@ -402,9 +402,9 @@ describe('Batch comments store actions', () => {
actions
.
scrollToDraft
({
dispatch
,
rootGetters
},
draft
);
expect
(
dispatch
.
calls
.
argsFor
(
0
)
).
toEqual
([
'
closeReviewDropdown
'
]);
expect
(
dispatch
.
mock
.
calls
[
0
]
).
toEqual
([
'
closeReviewDropdown
'
]);
expect
(
dispatch
.
calls
.
argsFor
(
1
)
).
toEqual
([
expect
(
dispatch
.
mock
.
calls
[
1
]
).
toEqual
([
'
expandDiscussion
'
,
{
discussionId
:
'
1
'
},
{
root
:
true
},
...
...
ee/spec/javascripts/batch_comments/mock_data.js
View file @
89781e30
// eslint-disable-next-line import/prefer-default-export
export
const
createDraft
=
()
=>
({
author
:
{
id
:
1
,
name
:
'
Test
'
,
username
:
'
test
'
,
state
:
'
active
'
,
avatar_url
:
gl
.
TEST_HOST
,
},
current_user
:
{
can_edit
:
true
,
can_award_emoji
:
false
,
can_resolve
:
false
},
discussion_id
:
null
,
file_hash
:
null
,
file_path
:
null
,
id
:
1
,
line_code
:
null
,
merge_request_id
:
1
,
note
:
'
a
'
,
note_html
:
'
<p>Test</p>
'
,
noteable_type
:
'
MergeRequest
'
,
references
:
{
users
:
[],
commands
:
''
},
resolve_discussion
:
false
,
isDraft
:
true
,
position
:
null
,
});
// No new code should be added to this file. Instead, modify the
// file this one re-exports from. For more detail about why, see:
// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/31349
export
*
from
'
../../frontend/batch_comments/mock_data
'
;
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