Commit 6c6bd840 authored by Illya Klymov's avatar Illya Klymov

Replace usage of find/findAll in ee/spec/frontend/compliance_dashboard

* migrate to proper use of findComponent/findAllComponents
parent 68755b38
...@@ -8,7 +8,7 @@ const IMAGE_PATH = 'empty.svg'; ...@@ -8,7 +8,7 @@ const IMAGE_PATH = 'empty.svg';
describe('EmptyState component', () => { describe('EmptyState component', () => {
let wrapper; let wrapper;
const emptyStateProp = (prop) => wrapper.find(GlEmptyState).props(prop); const emptyStateProp = (prop) => wrapper.findComponent(GlEmptyState).props(prop);
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
return shallowMount(EmptyState, { return shallowMount(EmptyState, {
......
...@@ -10,7 +10,7 @@ describe('MergeRequest component', () => { ...@@ -10,7 +10,7 @@ describe('MergeRequest component', () => {
const findMessage = () => wrapper.find('[data-testid="approvers"]'); const findMessage = () => wrapper.find('[data-testid="approvers"]');
const findCounter = () => wrapper.find('.avatar-counter'); const findCounter = () => wrapper.find('.avatar-counter');
const findAvatarLinks = () => wrapper.findAll(GlAvatarLink); const findAvatarLinks = () => wrapper.findAllComponents(GlAvatarLink);
const createComponent = (approvers = []) => { const createComponent = (approvers = []) => {
return shallowMount(Approvers, { return shallowMount(Approvers, {
......
...@@ -9,12 +9,12 @@ const CSV_EXPORT_PATH = '/merge_commit_reports'; ...@@ -9,12 +9,12 @@ const CSV_EXPORT_PATH = '/merge_commit_reports';
describe('MergeCommitsExportButton component', () => { describe('MergeCommitsExportButton component', () => {
let wrapper; let wrapper;
const findCommitForm = () => wrapper.find(GlForm); const findCommitForm = () => wrapper.findComponent(GlForm);
const findCommitInput = () => wrapper.find(GlFormInput); const findCommitInput = () => wrapper.findComponent(GlFormInput);
const findCommitInputGroup = () => wrapper.find(GlFormGroup); const findCommitInputGroup = () => wrapper.findComponent(GlFormGroup);
const findCommitInputFeedback = () => wrapper.find('.invalid-feedback'); const findCommitInputFeedback = () => wrapper.find('.invalid-feedback');
const findCommitExportButton = () => wrapper.find('[data-test-id="merge-commit-submit-button"]'); const findCommitExportButton = () => wrapper.find('[data-test-id="merge-commit-submit-button"]');
const findCsvExportButton = () => wrapper.find({ ref: 'listMergeCommitsButton' }); const findCsvExportButton = () => wrapper.findComponent({ ref: 'listMergeCommitsButton' });
const createComponent = ({ mountFn = shallowMount, data = {} } = {}) => { const createComponent = ({ mountFn = shallowMount, data = {} } = {}) => {
return mountFn(MergeCommitsExportButton, { return mountFn(MergeCommitsExportButton, {
......
...@@ -9,7 +9,7 @@ import { createMergeRequest } from '../../mock_data'; ...@@ -9,7 +9,7 @@ import { createMergeRequest } from '../../mock_data';
describe('MergeRequest component', () => { describe('MergeRequest component', () => {
let wrapper; let wrapper;
const findAuthorAvatarLink = () => wrapper.find('.issuable-authored').find(GlAvatarLink); const findAuthorAvatarLink = () => wrapper.find('.issuable-authored').findComponent(GlAvatarLink);
const findComplianceFrameworkLabel = () => wrapper.findComponent(ComplianceFrameworkLabel); const findComplianceFrameworkLabel = () => wrapper.findComponent(ComplianceFrameworkLabel);
const createComponent = (mergeRequest) => { const createComponent = (mergeRequest) => {
...@@ -54,7 +54,7 @@ describe('MergeRequest component', () => { ...@@ -54,7 +54,7 @@ describe('MergeRequest component', () => {
}); });
it('renders the author avatar', () => { it('renders the author avatar', () => {
expect(findAuthorAvatarLink().find(GlAvatar).exists()).toEqual(true); expect(findAuthorAvatarLink().findComponent(GlAvatar).exists()).toEqual(true);
}); });
it('renders the author name', () => { it('renders the author name', () => {
......
...@@ -16,9 +16,9 @@ describe('Status component', () => { ...@@ -16,9 +16,9 @@ describe('Status component', () => {
const checkStatusComponentExists = (status, exists) => { const checkStatusComponentExists = (status, exists) => {
switch (status.type) { switch (status.type) {
case 'approval': case 'approval':
return expect(wrapper.find(Approval).exists()).toBe(exists); return expect(wrapper.findComponent(Approval).exists()).toBe(exists);
case 'pipeline': case 'pipeline':
return expect(wrapper.find(Pipeline).exists()).toBe(exists); return expect(wrapper.findComponent(Pipeline).exists()).toBe(exists);
default: default:
throw new Error(`Unknown status type: ${status.type}`); throw new Error(`Unknown status type: ${status.type}`);
} }
......
...@@ -7,7 +7,7 @@ describe('ApprovalStatus component', () => { ...@@ -7,7 +7,7 @@ describe('ApprovalStatus component', () => {
let wrapper; let wrapper;
const findIcon = () => wrapper.find('.ci-icon'); const findIcon = () => wrapper.find('.ci-icon');
const findLink = () => wrapper.find(GlLink); const findLink = () => wrapper.findComponent(GlLink);
const createComponent = (status) => { const createComponent = (status) => {
return shallowMount(Approval, { return shallowMount(Approval, {
......
...@@ -8,7 +8,7 @@ describe('Pipeline component', () => { ...@@ -8,7 +8,7 @@ describe('Pipeline component', () => {
let wrapper; let wrapper;
const findCiIcon = () => wrapper.find('.ci-icon'); const findCiIcon = () => wrapper.find('.ci-icon');
const findCiLink = () => wrapper.find(GlLink); const findCiLink = () => wrapper.findComponent(GlLink);
const createComponent = (status) => { const createComponent = (status) => {
return shallowMount(Pipeline, { return shallowMount(Pipeline, {
......
...@@ -88,7 +88,7 @@ describe('ComplianceReport component', () => { ...@@ -88,7 +88,7 @@ describe('ComplianceReport component', () => {
}); });
it('renders the subheading with a help link', () => { it('renders the subheading with a help link', () => {
const helpLink = findSubheading().find(GlLink); const helpLink = findSubheading().findComponent(GlLink);
expect(findSubheading().text()).toContain( expect(findSubheading().text()).toContain(
'The compliance report shows the merge request violations merged in protected environments.', 'The compliance report shows the merge request violations merged in protected environments.',
......
...@@ -35,7 +35,7 @@ describe('BranchDetails component', () => { ...@@ -35,7 +35,7 @@ describe('BranchDetails component', () => {
}); });
it('has no links', () => { it('has no links', () => {
expect(wrapper.find(GlLink).exists()).toBe(false); expect(wrapper.findComponent(GlLink).exists()).toBe(false);
}); });
it('has the correct text', () => { it('has the correct text', () => {
...@@ -49,7 +49,7 @@ describe('BranchDetails component', () => { ...@@ -49,7 +49,7 @@ describe('BranchDetails component', () => {
}); });
it('has one link', () => { it('has one link', () => {
expect(wrapper.findAll(GlLink)).toHaveLength(1); expect(wrapper.findAllComponents(GlLink)).toHaveLength(1);
}); });
it('has a link to the target branch', () => { it('has a link to the target branch', () => {
...@@ -67,7 +67,7 @@ describe('BranchDetails component', () => { ...@@ -67,7 +67,7 @@ describe('BranchDetails component', () => {
}); });
it('has two links', () => { it('has two links', () => {
expect(wrapper.findAll(GlLink)).toHaveLength(2); expect(wrapper.findAllComponents(GlLink)).toHaveLength(2);
}); });
it('has a link to the source branch', () => { it('has a link to the source branch', () => {
......
...@@ -7,7 +7,7 @@ describe('Pagination component', () => { ...@@ -7,7 +7,7 @@ describe('Pagination component', () => {
let wrapper; let wrapper;
const origin = 'https://localhost'; const origin = 'https://localhost';
const findGlPagination = () => wrapper.find(GlPagination); const findGlPagination = () => wrapper.findComponent(GlPagination);
const getLink = (query) => wrapper.find(query).element.getAttribute('href'); const getLink = (query) => wrapper.find(query).element.getAttribute('href');
const findPrevPageLink = () => getLink('a.prev-page-item'); const findPrevPageLink = () => getLink('a.prev-page-item');
const findNextPageLink = () => getLink('a.next-page-item'); const findNextPageLink = () => getLink('a.next-page-item');
......
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