Added spec for testing the issuable count
This commit is contained in:
parent
a57597108f
commit
37bbdb604c
3 changed files with 32 additions and 26 deletions
|
@ -1,5 +0,0 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
Unstarted Issues (open and unassigned)
|
||||
.pull-right
|
||||
1
|
|
@ -1,21 +0,0 @@
|
|||
/*= require jquery */
|
||||
(() => {
|
||||
describe('MilestonePanel', () => {
|
||||
const issuesCount = '.pull-right';
|
||||
const fixtureTemplate = 'issuables.html';
|
||||
|
||||
function setIssuesCount(newCount) {
|
||||
$(issuesCount).text(newCount);
|
||||
}
|
||||
|
||||
fixture.preload(fixtureTemplate);
|
||||
beforeEach(() => {
|
||||
fixture.load(fixtureTemplate);
|
||||
});
|
||||
|
||||
it('should add delimiter to the issues count', () => {
|
||||
setIssuesCount(1000);
|
||||
expect($(issuesCount).text()).toEqual('1,000');
|
||||
});
|
||||
});
|
||||
})();
|
32
spec/views/shared/milestones/_issuables.html.haml.rb
Normal file
32
spec/views/shared/milestones/_issuables.html.haml.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'shared/milestones/_issuables.html.haml' do
|
||||
let(:issuables_size) { 100 }
|
||||
|
||||
before do
|
||||
allow(view).to receive_messages(title: nil, id: nil, show_project_name: nil,
|
||||
show_full_project_name: nil, dom_class: '',
|
||||
issuables: double(size: issuables_size).as_null_object)
|
||||
|
||||
stub_template 'shared/milestones/_issuable.html.haml' => ''
|
||||
end
|
||||
|
||||
it 'should show the issuables count if show_counter is true' do
|
||||
render 'shared/milestones/issuables', show_counter: true
|
||||
expect(rendered).to have_content('100')
|
||||
end
|
||||
|
||||
it 'should not show the issuables count if show_counter is false' do
|
||||
render 'shared/milestones/issuables', show_counter: false
|
||||
expect(rendered).not_to have_content('100')
|
||||
end
|
||||
|
||||
describe 'a high issuables count' do
|
||||
let(:issuables_size) { 1000 }
|
||||
|
||||
it 'should show a delimited number if show_counter is true' do
|
||||
render 'shared/milestones/issuables', show_counter: true
|
||||
expect(rendered).to have_content('1,000')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue