diff options
Diffstat (limited to 'spec/frontend/pipelines/time_ago_spec.js')
-rw-r--r-- | spec/frontend/pipelines/time_ago_spec.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/spec/frontend/pipelines/time_ago_spec.js b/spec/frontend/pipelines/time_ago_spec.js index efb1bf09d20..ccc07d9b1a8 100644 --- a/spec/frontend/pipelines/time_ago_spec.js +++ b/spec/frontend/pipelines/time_ago_spec.js @@ -8,7 +8,7 @@ describe('Timeago component', () => { const defaultProps = { duration: 0, finished_at: '' }; - const createComponent = (props = defaultProps, stuck = false) => { + const createComponent = (props = defaultProps, stuck = false, extraProps) => { wrapper = extendedWrapper( shallowMount(TimeAgo, { propsData: { @@ -20,6 +20,7 @@ describe('Timeago component', () => { stuck, }, }, + ...extraProps, }, data() { return { @@ -36,6 +37,7 @@ describe('Timeago component', () => { const findSkipped = () => wrapper.findByTestId('pipeline-skipped'); const findHourGlassIcon = () => wrapper.findByTestId('hourglass-icon'); const findWarningIcon = () => wrapper.findByTestId('warning-icon'); + const findCalendarIcon = () => wrapper.findByTestId('calendar-icon'); describe('with duration', () => { beforeEach(() => { @@ -61,18 +63,28 @@ describe('Timeago component', () => { }); describe('with finishedTime', () => { - beforeEach(() => { + it('should render time', () => { createComponent({ duration: 0, finished_at: '2017-04-26T12:40:23.277Z' }); - }); - it('should render time and calendar icon', () => { - const icon = finishedAt().findComponent(GlIcon); const time = finishedAt().find('time'); expect(finishedAt().exists()).toBe(true); - expect(icon.props('name')).toBe('calendar'); expect(time.exists()).toBe(true); }); + + it('should display calendar icon by default', () => { + createComponent({ duration: 0, finished_at: '2017-04-26T12:40:23.277Z' }); + + expect(findCalendarIcon().exists()).toBe(true); + }); + + it('should hide calendar icon if correct prop is passed', () => { + createComponent({ duration: 0, finished_at: '2017-04-26T12:40:23.277Z' }, false, { + displayCalendarIcon: false, + }); + + expect(findCalendarIcon().exists()).toBe(false); + }); }); describe('without finishedTime', () => { @@ -82,6 +94,7 @@ describe('Timeago component', () => { it('should not render time and calendar icon', () => { expect(finishedAt().exists()).toBe(false); + expect(findCalendarIcon().exists()).toBe(false); }); }); |