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
33318a56
Commit
33318a56
authored
Oct 12, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update milestone select spec
parent
c42728f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
81 deletions
+102
-81
app/assets/javascripts/boards/components/milestone_select.vue
...assets/javascripts/boards/components/milestone_select.vue
+1
-0
spec/javascripts/boards/milestone_select_spec.js
spec/javascripts/boards/milestone_select_spec.js
+101
-81
No files found.
app/assets/javascripts/boards/components/milestone_select.vue
View file @
33318a56
<
script
>
<
script
>
/* global BoardService, MilestoneSelect */
/* global BoardService, MilestoneSelect */
import
'
~/milestone_select
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
const
ANY_MILESTONE
=
'
Any Milestone
'
;
const
ANY_MILESTONE
=
'
Any Milestone
'
;
...
...
spec/javascripts/boards/milestone_select_spec.js
View file @
33318a56
...
@@ -2,135 +2,155 @@
...
@@ -2,135 +2,155 @@
/* global boardObj */
/* global boardObj */
/* global BoardService */
/* global BoardService */
/* global mockBoardService */
/* global mockBoardService */
/* global IssuableContext */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
MilestoneSelect
from
'
~/boards/components/milestone_select.vue
'
;
import
MilestoneSelect
from
'
~/boards/components/milestone_select.vue
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/boards/stores/boards_store
'
;
import
'
~/issuable_context
'
;
import
'
./mock_data
'
;
import
'
./mock_data
'
;
describe
(
'
Milestone select component
'
,
()
=>
{
let
vm
;
let
selectMilestoneSpy
;
let
vm
;
function
selectedText
()
{
return
vm
.
$el
.
querySelector
(
'
.value
'
).
innerText
.
trim
();
}
function
activeDropdownItem
(
index
)
{
const
items
=
document
.
querySelectorAll
(
'
.is-active
'
);
if
(
!
items
[
index
])
return
''
;
return
items
[
index
].
innerText
.
trim
();
}
const
milestone
=
{
id
:
1
,
title
:
'
first milestone
'
,
name
:
'
first milestone
'
,
};
const
milestone2
=
{
id
:
2
,
title
:
'
second milestone
'
,
name
:
'
second milestone
'
,
};
beforeEach
(()
=>
{
describe
(
'
Milestone select component
'
,
()
=>
{
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
beforeEach
((
done
)
=>
{
setFixtures
(
'
<div class="test-container"></div>
'
);
gl
.
boardService
=
mockBoardService
();
gl
.
boardService
=
mockBoardService
();
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
create
();
selectMilestoneSpy
=
jasmine
.
createSpy
(
'
selectMilestone
'
).
and
.
callFake
((
milestone
)
=>
{
// eslint-disable-next-line no-new
vm
.
board
.
milestone_id
=
milestone
.
id
;
new
IssuableContext
();
});
vm
=
new
MilestoneSelect
({
const
Component
=
Vue
.
extend
(
MilestoneSelect
);
vm
=
new
Component
({
propsData
:
{
propsData
:
{
board
:
boardObj
,
board
:
boardObj
,
milestonePath
:
'
/test/issue-boards/milestones.json
'
,
milestonePath
:
'
/test/issue-boards/milestones.json
'
,
selectMilestone
:
selectMilestoneSpy
,
canEdit
:
true
,
},
},
});
}).
$mount
(
'
.test-container
'
);
});
afterEach
(()
=>
{
setTimeout
(
done
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
});
});
describe
(
'
before mount
'
,
()
=>
{
describe
(
'
canEdit
'
,
()
=>
{
it
(
'
sets default data
'
,
()
=>
{
it
(
'
hides Edit button
'
,
(
done
)
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
vm
.
canEdit
=
false
;
expect
(
vm
.
milestones
.
length
).
toBe
(
0
);
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
extraMilestones
.
length
).
toBe
(
3
);
expect
(
document
.
querySelector
(
'
.edit-link
'
)).
toBeFalsy
();
expect
(
vm
.
extraMilestones
[
0
].
title
).
toBe
(
'
Any Milestone
'
);
done
();
expect
(
vm
.
extraMilestones
[
1
].
title
).
toBe
(
'
Upcoming
'
);
});
expect
(
vm
.
extraMilestones
[
2
].
title
).
toBe
(
'
Started
'
);
});
it
(
'
shows Edit button if true
'
,
(
done
)
=>
{
vm
.
canEdit
=
true
;
Vue
.
nextTick
(()
=>
{
expect
(
document
.
querySelector
(
'
.edit-link
'
)).
toBeTruthy
();
done
();
});
});
});
});
});
describe
(
'
mounted
'
,
()
=>
{
describe
(
'
selected value
'
,
()
=>
{
describe
(
'
without board m
ilestone
'
,
()
=>
{
it
(
'
defaults to Any M
ilestone
'
,
()
=>
{
beforeEach
((
done
)
=>
{
expect
(
selectedText
()).
toContain
(
'
Any Milestone
'
);
vm
.
$mount
(
);
}
);
setTimeout
(()
=>
{
it
(
'
shows No Milestone
'
,
(
done
)
=>
{
done
();
vm
.
board
.
milestone_id
=
0
;
});
Vue
.
nextTick
(()
=>
{
expect
(
selectedText
()).
toContain
(
'
No Milestone
'
);
done
();
});
});
});
it
(
'
loads data
'
,
()
=>
{
it
(
'
shows selected milestone title
'
,
(
done
)
=>
{
expect
(
vm
.
milestones
.
length
).
toBe
(
1
);
vm
.
board
.
milestone_id
=
20
;
vm
.
board
.
milestone
=
{
id
:
20
,
title
:
'
Selected milestone
'
,
};
Vue
.
nextTick
(()
=>
{
expect
(
selectedText
()).
toContain
(
'
Selected milestone
'
);
done
();
});
});
});
it
(
'
renders the milestone list
'
,
()
=>
{
describe
(
'
clicking dropdown items
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.fa-spinner
'
)).
toBeNull
();
beforeEach
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list li
'
).
length
).
toBe
(
5
);
const
deferred
=
new
jQuery
.
Deferred
();
expect
(
spyOn
(
$
,
'
ajax
'
).
and
.
returnValue
(
deferred
.
resolve
([
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list li
'
)[
4
].
textContent
,
milestone
,
).
toContain
(
'
test
'
);
milestone2
,
]));
});
});
it
(
'
selects any milestone
'
,
()
=>
{
it
(
'
sets Any Milestone
'
,
(
done
)
=>
{
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
0
].
click
();
vm
.
board
.
milestone_id
=
0
;
vm
.
$el
.
querySelector
(
'
.edit-link
'
).
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
setTimeout
(()
=>
{
id
:
null
,
vm
.
$el
.
querySelectorAll
(
'
li a
'
)[
0
].
click
();
title
:
'
Any Milestone
'
,
});
});
});
it
(
'
selects upcoming milestone
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
1
].
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
setTimeout
(()
=>
{
id
:
-
2
,
expect
(
activeDropdownItem
(
0
)).
toEqual
(
'
Any Milestone
'
);
title
:
'
Upcoming
'
,
expect
(
selectedText
()).
toEqual
(
'
Any Milestone
'
);
done
();
});
});
});
});
it
(
'
se
lects started milestone
'
,
(
)
=>
{
it
(
'
se
ts No Milestone
'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
All
(
'
.board-milestone-list a
'
)[
2
]
.
click
();
vm
.
$el
.
querySelector
(
'
.edit-link
'
)
.
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
setTimeout
(()
=>
{
id
:
-
3
,
vm
.
$el
.
querySelectorAll
(
'
li a
'
)[
1
].
click
();
title
:
'
Started
'
,
});
});
});
it
(
'
selects fetched milestone
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
3
].
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
setTimeout
(()
=>
{
id
:
1
,
expect
(
activeDropdownItem
(
0
)).
toEqual
(
'
No Milestone
'
);
title
:
'
test
'
,
expect
(
selectedText
()).
toEqual
(
'
No Milestone
'
);
done
();
});
});
});
});
it
(
'
changes selected
milestone
'
,
(
done
)
=>
{
it
(
'
sets
milestone
'
,
(
done
)
=>
{
const
firstLink
=
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
0
]
;
vm
.
$el
.
querySelector
(
'
.edit-link
'
).
click
()
;
firstLink
.
click
();
setTimeout
(()
=>
{
vm
.
$el
.
querySelectorAll
(
'
li a
'
)[
4
].
click
();
Vue
.
nextTick
(()
=>
{
expect
(
firstLink
.
querySelector
(
'
.fa-check
'
)).
toBeDefined
();
done
();
});
});
});
});
describe
(
'
with board milestone
'
,
()
=>
{
beforeEach
((
done
)
=>
{
vm
.
board
.
milestone_id
=
1
;
vm
.
$mount
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
activeDropdownItem
(
0
)).
toEqual
(
'
first milestone
'
);
expect
(
selectedText
()).
toEqual
(
'
first milestone
'
);
expect
(
vm
.
board
.
milestone
).
toEqual
(
milestone
);
done
();
done
();
});
});
});
});
it
(
'
renders the selected milestone
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.board-milestone-list .fa-check
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list .fa-check
'
).
length
).
toBe
(
1
);
});
});
});
});
});
});
});
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