diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:09:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:09:28 +0300 |
commit | 14fb5a922285d71fea67de59164ee4bb81ee3486 (patch) | |
tree | d3f585c54feb676aec2f14cc85fe32d615fd7fc0 /spec/frontend/incidents | |
parent | d9b0b3243e3cd71a08ff5d4035b7882cc7a5a35f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/incidents')
-rw-r--r-- | spec/frontend/incidents/components/incidents_list_spec.js | 28 | ||||
-rw-r--r-- | spec/frontend/incidents/mocks/incidents.json | 26 |
2 files changed, 43 insertions, 11 deletions
diff --git a/spec/frontend/incidents/components/incidents_list_spec.js b/spec/frontend/incidents/components/incidents_list_spec.js index 0a723ab15a1..05177a761c2 100644 --- a/spec/frontend/incidents/components/incidents_list_spec.js +++ b/spec/frontend/incidents/components/incidents_list_spec.js @@ -1,7 +1,9 @@ import { mount } from '@vue/test-utils'; import { GlAlert, GlLoadingIcon, GlTable } from '@gitlab/ui'; import IncidentsList from '~/incidents/components/incidents_list.vue'; +import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import { I18N } from '~/incidents/constants'; +import mockIncidents from '../mocks/incidents.json'; describe('Incidents List', () => { let wrapper; @@ -10,6 +12,7 @@ describe('Incidents List', () => { const findTableRows = () => wrapper.findAll('table tbody tr'); const findAlert = () => wrapper.find(GlAlert); const findLoader = () => wrapper.find(GlLoadingIcon); + const findTimeAgo = () => wrapper.findAll(TimeAgoTooltip); function mountComponent({ data = { incidents: [] }, loading = false }) { wrapper = mount(IncidentsList, { @@ -40,7 +43,6 @@ describe('Incidents List', () => { it('shows the loading state', () => { mountComponent({ - props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, loading: true, }); expect(findLoader().exists()).toBe(true); @@ -63,16 +65,20 @@ describe('Incidents List', () => { expect(findAlert().exists()).toBe(true); }); - it('displays basic list', () => { - const incidents = [ - { title: 1, assignees: [] }, - { title: 2, assignees: [] }, - { title: 3, assignees: [] }, - ]; - mountComponent({ - data: { incidents }, - loading: false, + describe('Incident Management list', () => { + beforeEach(() => { + mountComponent({ + data: { incidents: mockIncidents }, + loading: false, + }); + }); + + it('renders rows based on provided data', () => { + expect(findTableRows().length).toBe(mockIncidents.length); + }); + + it('renders a createdAt with timeAgo component per row', () => { + expect(findTimeAgo().length).toBe(mockIncidents.length); }); - expect(findTableRows().length).toBe(incidents.length); }); }); diff --git a/spec/frontend/incidents/mocks/incidents.json b/spec/frontend/incidents/mocks/incidents.json new file mode 100644 index 00000000000..e3de5d7b929 --- /dev/null +++ b/spec/frontend/incidents/mocks/incidents.json @@ -0,0 +1,26 @@ +[ + { + "iid": "15", + "title": "New: Incident", + "createdAt": "2020-06-03T15:46:08Z", + "assignees": {} + }, + { + "iid": "14", + "title": "Create issue4", + "createdAt": "2020-05-19T09:26:07Z", + "assignees": {} + }, + { + "iid": "13", + "title": "Create issue3", + "createdAt": "2020-05-19T08:53:55Z", + "assignees": {} + }, + { + "iid": "12", + "title": "Create issue2", + "createdAt": "2020-05-18T17:13:35Z", + "assignees": {} + } +] |