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
b9a52cb6
Commit
b9a52cb6
authored
Feb 16, 2017
by
Phil Hughes
Committed by
Douglas Barbosa Alexandre
Mar 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added milestone component spec
parent
7e3c8438
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
2 deletions
+125
-2
spec/javascripts/boards/milestone_select_spec.js
spec/javascripts/boards/milestone_select_spec.js
+113
-0
spec/javascripts/boards/mock_data.js
spec/javascripts/boards/mock_data.js
+12
-2
No files found.
spec/javascripts/boards/milestone_select_spec.js
0 → 100644
View file @
b9a52cb6
/* global Vue */
/* global boardsMockInterceptor */
/* global BoardService */
const
MilestoneComp
=
require
(
'
~/boards/components/milestone_select
'
);
require
(
'
~/boards/services/board_service
'
);
require
(
'
~/boards/stores/boards_store
'
);
require
(
'
./mock_data
'
);
describe
(
'
Milestone select component
'
,
()
=>
{
let
selectMilestoneSpy
;
let
vm
;
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
boardsMockInterceptor
);
gl
.
boardService
=
new
BoardService
(
'
/test/issue-boards/board
'
,
''
,
'
1
'
);
gl
.
issueBoards
.
BoardsStore
.
create
();
selectMilestoneSpy
=
jasmine
.
createSpy
(
'
selectMilestone
'
).
and
.
callFake
((
milestone
)
=>
{
vm
.
board
.
milestone_id
=
milestone
.
id
;
});
vm
=
new
MilestoneComp
({
propsData
:
{
board
:
boardObj
,
milestonePath
:
'
/test/issue-boards/milestones.json
'
,
selectMilestone
:
selectMilestoneSpy
,
},
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
boardsMockInterceptor
);
});
describe
(
'
before mount
'
,
()
=>
{
it
(
'
sets default data
'
,
()
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
expect
(
vm
.
milestones
.
length
).
toBe
(
0
);
expect
(
vm
.
extraMilestones
.
length
).
toBe
(
1
);
expect
(
vm
.
extraMilestones
[
0
].
title
).
toBe
(
'
Any Milestone
'
);
});
});
describe
(
'
mounted
'
,
()
=>
{
describe
(
'
without board milestone
'
,
()
=>
{
beforeEach
((
done
)
=>
{
vm
.
$mount
();
setTimeout
(()
=>
{
done
();
});
});
it
(
'
loads data
'
,
()
=>
{
expect
(
vm
.
milestones
.
length
).
toBe
(
1
);
});
it
(
'
renders the milestone list
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.fa-spinner
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list li
'
).
length
).
toBe
(
3
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list li
'
)[
2
].
textContent
).
toContain
(
'
test
'
);
});
it
(
'
selects any milestone
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
0
].
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
id
:
null
,
title
:
'
Any Milestone
'
,
});
});
it
(
'
selects fetched milestone
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
1
].
click
();
expect
(
selectMilestoneSpy
).
toHaveBeenCalledWith
({
id
:
1
,
title
:
'
test
'
,
});
});
it
(
'
changes selected milestone
'
,
(
done
)
=>
{
const
firstLink
=
vm
.
$el
.
querySelectorAll
(
'
.board-milestone-list a
'
)[
0
];
firstLink
.
click
();
Vue
.
nextTick
(()
=>
{
expect
(
firstLink
.
querySelector
(
'
.fa-check
'
)).
toBeDefined
();
done
();
});
});
});
describe
(
'
with board milestone
'
,
()
=>
{
beforeEach
((
done
)
=>
{
vm
.
board
.
milestone_id
=
1
;
vm
.
$mount
();
setTimeout
(()
=>
{
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
);
});
});
});
});
spec/javascripts/boards/mock_data.js
View file @
b9a52cb6
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
const
boardObj
=
{
id
:
1
,
name
:
'
test
'
,
milestone_id
:
null
,
};
const
listObj
=
{
id
:
1
,
...
...
@@ -36,7 +41,11 @@ const BoardsMockData = {
labels
:
[]
}],
size
:
1
}
},
'
/test/issue-boards/milestones.json
'
:
[{
id
:
1
,
title
:
'
test
'
,
}],
},
'
POST
'
:
{
'
/test/issue-boards/board/1/lists{/id}
'
:
listObj
...
...
@@ -50,13 +59,14 @@ const BoardsMockData = {
};
const
boardsMockInterceptor
=
(
request
,
next
)
=>
{
const
body
=
BoardsMockData
[
request
.
method
][
request
.
url
];
const
body
=
BoardsMockData
[
request
.
method
.
toUpperCase
()
][
request
.
url
];
next
(
request
.
respondWith
(
JSON
.
stringify
(
body
),
{
status
:
200
}));
};
window
.
boardObj
=
boardObj
;
window
.
listObj
=
listObj
;
window
.
listObjDuplicate
=
listObjDuplicate
;
window
.
BoardsMockData
=
BoardsMockData
;
...
...
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