Commit 72fc4059 authored by Phil Hughes's avatar Phil Hughes Committed by Douglas Barbosa Alexandre

Fixed up failing JS tests

Added upcoming tests
parent 7e5e2144
...@@ -96,7 +96,7 @@ require('./board_new_form'); ...@@ -96,7 +96,7 @@ require('./board_new_form');
}, },
updateMilestoneFilterDropdown() { updateMilestoneFilterDropdown() {
const $milestoneDropdown = $('.dropdown-menu-milestone'); const $milestoneDropdown = $('.dropdown-menu-milestone');
const hideElements = this.board.milestone === null || this.board.milestone.id === -1; const hideElements = this.board.milestone === undefined || this.board.milestone_id === -1;
$milestoneDropdown.find('.dropdown-input, .dropdown-footer-list') $milestoneDropdown.find('.dropdown-input, .dropdown-footer-list')
.toggle(hideElements); .toggle(hideElements);
......
...@@ -26,8 +26,8 @@ module.exports = Vue.extend({ ...@@ -26,8 +26,8 @@ module.exports = Vue.extend({
}, },
{ {
id: -2, id: -2,
title: 'Upcoming' title: 'Upcoming',
} },
], ],
}; };
}, },
......
...@@ -58,6 +58,20 @@ describe 'Multiple Issue Boards', :feature, :js do ...@@ -58,6 +58,20 @@ describe 'Multiple Issue Boards', :feature, :js do
expect(find('.js-milestone-select')).not_to have_content(milestone.title) expect(find('.js-milestone-select')).not_to have_content(milestone.title)
expect(all('.board')[1]).to have_selector('.card', count: 2) expect(all('.board')[1]).to have_selector('.card', count: 2)
end end
it 'sets board to any milestone' do
update_board_milestone('Any Milestone')
expect(find('.js-milestone-select')).not_to have_content(milestone.title)
expect(all('.board')[1]).to have_selector('.card', count: 2)
end
it 'sets board to upcoming milestone' do
update_board_milestone('Upcoming')
expect(find('.js-milestone-select')).not_to have_content(milestone.title)
expect(all('.board')[1]).to have_selector('.card', count: 0)
end
end end
def create_board_with_milestone def create_board_with_milestone
......
...@@ -37,8 +37,9 @@ describe('Milestone select component', () => { ...@@ -37,8 +37,9 @@ describe('Milestone select component', () => {
it('sets default data', () => { it('sets default data', () => {
expect(vm.loading).toBe(false); expect(vm.loading).toBe(false);
expect(vm.milestones.length).toBe(0); expect(vm.milestones.length).toBe(0);
expect(vm.extraMilestones.length).toBe(1); expect(vm.extraMilestones.length).toBe(2);
expect(vm.extraMilestones[0].title).toBe('Any Milestone'); expect(vm.extraMilestones[0].title).toBe('Any Milestone');
expect(vm.extraMilestones[1].title).toBe('Upcoming');
}); });
}); });
...@@ -58,9 +59,9 @@ describe('Milestone select component', () => { ...@@ -58,9 +59,9 @@ describe('Milestone select component', () => {
it('renders the milestone list', () => { it('renders the milestone list', () => {
expect(vm.$el.querySelector('.fa-spinner')).toBeNull(); 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').length).toBe(4);
expect( expect(
vm.$el.querySelectorAll('.board-milestone-list li')[2].textContent, vm.$el.querySelectorAll('.board-milestone-list li')[3].textContent,
).toContain('test'); ).toContain('test');
}); });
...@@ -73,9 +74,18 @@ describe('Milestone select component', () => { ...@@ -73,9 +74,18 @@ describe('Milestone select component', () => {
}); });
}); });
it('selects fetched milestone', () => { it('selects upcoming milestone', () => {
vm.$el.querySelectorAll('.board-milestone-list a')[1].click(); vm.$el.querySelectorAll('.board-milestone-list a')[1].click();
expect(selectMilestoneSpy).toHaveBeenCalledWith({
id: -2,
title: 'Upcoming',
});
});
it('selects fetched milestone', () => {
vm.$el.querySelectorAll('.board-milestone-list a')[2].click();
expect(selectMilestoneSpy).toHaveBeenCalledWith({ expect(selectMilestoneSpy).toHaveBeenCalledWith({
id: 1, id: 1,
title: 'test', title: 'test',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment