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
117ef41c
Commit
117ef41c
authored
Mar 06, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests for LabelsSelect component
parent
29e24f4c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
2 deletions
+88
-2
spec/javascripts/epics/epic_show/components/epic_show_app_spec.js
...ascripts/epics/epic_show/components/epic_show_app_spec.js
+11
-0
spec/javascripts/epics/sidebar/components/sidebar_app_spec.js
.../javascripts/epics/sidebar/components/sidebar_app_spec.js
+77
-2
No files found.
spec/javascripts/epics/epic_show/components/epic_show_app_spec.js
View file @
117ef41c
...
@@ -36,6 +36,11 @@ describe('EpicShowApp', () => {
...
@@ -36,6 +36,11 @@ describe('EpicShowApp', () => {
markdownDocsPath
,
markdownDocsPath
,
author
,
author
,
created
,
created
,
namespace
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
labels
,
}
=
props
;
}
=
props
;
const
EpicShowApp
=
Vue
.
extend
(
epicShowApp
);
const
EpicShowApp
=
Vue
.
extend
(
epicShowApp
);
...
@@ -72,6 +77,12 @@ describe('EpicShowApp', () => {
...
@@ -72,6 +77,12 @@ describe('EpicShowApp', () => {
editable
:
canUpdate
,
editable
:
canUpdate
,
initialStartDate
:
startDate
,
initialStartDate
:
startDate
,
initialEndDate
:
endDate
,
initialEndDate
:
endDate
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
namespace
,
});
});
setTimeout
(
done
);
setTimeout
(
done
);
...
...
spec/javascripts/epics/sidebar/components/sidebar_app_spec.js
View file @
117ef41c
...
@@ -3,15 +3,23 @@ import _ from 'underscore';
...
@@ -3,15 +3,23 @@ import _ from 'underscore';
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
epicSidebar
from
'
ee/epics/sidebar/components/sidebar_app.vue
'
;
import
epicSidebar
from
'
ee/epics/sidebar/components/sidebar_app.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
props
}
from
'
../../epic_show/mock_data
'
;
describe
(
'
epicSidebar
'
,
()
=>
{
describe
(
'
epicSidebar
'
,
()
=>
{
let
vm
;
let
vm
;
let
originalCookieState
;
let
originalCookieState
;
let
EpicSidebar
;
let
EpicSidebar
;
const
{
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
labels
,
}
=
props
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`
setFixtures
(
`
<div class="page-with-sidebar right-sidebar-expanded">
<div class="page-with-
contextual-
sidebar right-sidebar-expanded">
<div id="epic-sidebar"></div>
<div id="epic-sidebar"></div>
</div>
</div>
`
);
`
);
...
@@ -21,6 +29,11 @@ describe('epicSidebar', () => {
...
@@ -21,6 +29,11 @@ describe('epicSidebar', () => {
EpicSidebar
=
Vue
.
extend
(
epicSidebar
);
EpicSidebar
=
Vue
.
extend
(
epicSidebar
);
vm
=
mountComponent
(
EpicSidebar
,
{
vm
=
mountComponent
(
EpicSidebar
,
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
},
'
#epic-sidebar
'
);
},
'
#epic-sidebar
'
);
});
});
...
@@ -36,6 +49,11 @@ describe('epicSidebar', () => {
...
@@ -36,6 +49,11 @@ describe('epicSidebar', () => {
vm
=
mountComponent
(
EpicSidebar
,
{
vm
=
mountComponent
(
EpicSidebar
,
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialStartDate
:
'
2017-01-01
'
,
initialStartDate
:
'
2017-01-01
'
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
.value-content strong
'
).
innerText
.
trim
()).
toEqual
(
'
Jan 1, 2017
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.value-content strong
'
).
innerText
.
trim
()).
toEqual
(
'
Jan 1, 2017
'
);
...
@@ -45,6 +63,11 @@ describe('epicSidebar', () => {
...
@@ -45,6 +63,11 @@ describe('epicSidebar', () => {
vm
=
mountComponent
(
EpicSidebar
,
{
vm
=
mountComponent
(
EpicSidebar
,
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialEndDate
:
'
2018-01-01
'
,
initialEndDate
:
'
2018-01-01
'
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
.value-content strong
'
).
innerText
.
trim
()).
toEqual
(
'
Jan 1, 2018
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.value-content strong
'
).
innerText
.
trim
()).
toEqual
(
'
Jan 1, 2018
'
);
...
@@ -55,6 +78,11 @@ describe('epicSidebar', () => {
...
@@ -55,6 +78,11 @@ describe('epicSidebar', () => {
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialStartDate
:
'
2017-01-01
'
,
initialStartDate
:
'
2017-01-01
'
,
initialEndDate
:
'
2018-01-01
'
,
initialEndDate
:
'
2018-01-01
'
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
});
});
const
datePickers
=
vm
.
$el
.
querySelectorAll
(
'
.block
'
);
const
datePickers
=
vm
.
$el
.
querySelectorAll
(
'
.block
'
);
...
@@ -68,6 +96,11 @@ describe('epicSidebar', () => {
...
@@ -68,6 +96,11 @@ describe('epicSidebar', () => {
vm
=
mountComponent
(
EpicSidebar
,
{
vm
=
mountComponent
(
EpicSidebar
,
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialStartDate
:
'
2017-01-01
'
,
initialStartDate
:
'
2017-01-01
'
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
});
});
});
});
...
@@ -89,7 +122,7 @@ describe('epicSidebar', () => {
...
@@ -89,7 +122,7 @@ describe('epicSidebar', () => {
});
});
it
(
'
should toggle contentContainer css class
'
,
()
=>
{
it
(
'
should toggle contentContainer css class
'
,
()
=>
{
const
contentContainer
=
document
.
querySelector
(
'
.page-with-sidebar
'
);
const
contentContainer
=
document
.
querySelector
(
'
.page-with-
contextual-
sidebar
'
);
expect
(
contentContainer
.
classList
.
contains
(
'
right-sidebar-expanded
'
)).
toEqual
(
true
);
expect
(
contentContainer
.
classList
.
contains
(
'
right-sidebar-expanded
'
)).
toEqual
(
true
);
expect
(
contentContainer
.
classList
.
contains
(
'
right-sidebar-collapsed
'
)).
toEqual
(
false
);
expect
(
contentContainer
.
classList
.
contains
(
'
right-sidebar-collapsed
'
)).
toEqual
(
false
);
...
@@ -113,6 +146,11 @@ describe('epicSidebar', () => {
...
@@ -113,6 +146,11 @@ describe('epicSidebar', () => {
component
=
new
EpicSidebar
({
component
=
new
EpicSidebar
({
propsData
:
{
propsData
:
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
},
},
});
});
});
});
...
@@ -146,6 +184,38 @@ describe('epicSidebar', () => {
...
@@ -146,6 +184,38 @@ describe('epicSidebar', () => {
it
(
'
should handle errors gracefully
'
,
()
=>
{});
it
(
'
should handle errors gracefully
'
,
()
=>
{});
});
});
describe
(
'
handleLabelClick
'
,
()
=>
{
const
label
=
{
id
:
1
,
title
:
'
Foo
'
,
color
:
[
'
#BADA55
'
],
text_color
:
'
#FFFFFF
'
,
};
it
(
'
initializes `epicContext.labels` as empty array when `label.isAny` is `true`
'
,
()
=>
{
const
labelIsAny
=
{
isAny
:
true
};
vm
.
handleLabelClick
(
labelIsAny
);
expect
(
Array
.
isArray
(
vm
.
epicContext
.
labels
)).
toBe
(
true
);
expect
(
vm
.
epicContext
.
labels
.
length
).
toBe
(
0
);
});
it
(
'
adds provided `label` to epicContext.labels
'
,
()
=>
{
vm
.
handleLabelClick
(
label
);
// epicContext.labels gets initialized with initialLabels, hence
// newly insert label will be at second position (index `1`)
expect
(
vm
.
epicContext
.
labels
.
length
).
toBe
(
2
);
expect
(
vm
.
epicContext
.
labels
[
1
].
id
).
toBe
(
label
.
id
);
vm
.
handleLabelClick
(
label
);
});
it
(
'
filters epicContext.labels to exclude provided `label` if it is already present in `epicContext.labels`
'
,
()
=>
{
vm
.
handleLabelClick
(
label
);
// Select
vm
.
handleLabelClick
(
label
);
// Un-select
expect
(
vm
.
epicContext
.
labels
.
length
).
toBe
(
1
);
expect
(
vm
.
epicContext
.
labels
[
0
].
id
).
toBe
(
labels
[
0
].
id
);
});
});
describe
(
'
saveDate error
'
,
()
=>
{
describe
(
'
saveDate error
'
,
()
=>
{
let
interceptor
;
let
interceptor
;
let
component
;
let
component
;
...
@@ -160,6 +230,11 @@ describe('epicSidebar', () => {
...
@@ -160,6 +230,11 @@ describe('epicSidebar', () => {
component
=
new
EpicSidebar
({
component
=
new
EpicSidebar
({
propsData
:
{
propsData
:
{
endpoint
:
gl
.
TEST_HOST
,
endpoint
:
gl
.
TEST_HOST
,
initialLabels
:
labels
,
updatePath
:
updateEndpoint
,
labelsPath
,
labelsWebUrl
,
epicsWebUrl
,
},
},
});
});
});
});
...
...
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