Commit f9f66ce9 authored by Justin Ho's avatar Justin Ho

Fix all Jest specs

Most only need updates to selectors
parent 8dbe5cf0
......@@ -32,7 +32,7 @@ describe('ItemTypeIconComponent', () => {
vm = createComponent(ITEM_TYPE.GROUP);
expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('folder-icon');
expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('folder-o-icon');
vm.$destroy();
});
......
......@@ -23,7 +23,7 @@ describe('NavDropdown', () => {
vm.$mount();
};
const findIcon = name => vm.$el.querySelector(`[data-testid="${name}-icon]`);
const findIcon = name => vm.$el.querySelector(`[data-testid="${name}-icon"]`);
const findMRIcon = () => findIcon('merge-request');
const findBranchIcon = () => findIcon('branch');
......
......@@ -39,7 +39,7 @@ describe('IDE NavDropdown', () => {
});
};
const findIcon = name => wrapper.find(`.ic-${name}`);
const findIcon = name => wrapper.find(`[data-testid="${name}-icon"]`);
const findMRIcon = () => findIcon('merge-request');
const findNavForm = () => wrapper.find('.ide-nav-form');
const showDropdown = () => {
......
......@@ -42,6 +42,8 @@ describe('Job Log', () => {
wrapper.destroy();
});
const findCollapsibleLine = () => wrapper.find('.collapsible-line');
describe('line numbers', () => {
it('renders a line number for each open line', () => {
expect(wrapper.find('#L1').text()).toBe('1');
......@@ -56,18 +58,18 @@ describe('Job Log', () => {
describe('collapsible sections', () => {
it('renders a clickable header section', () => {
expect(wrapper.find('.collapsible-line').attributes('role')).toBe('button');
expect(findCollapsibleLine().attributes('role')).toBe('button');
});
it('renders an icon with the open state', () => {
expect(wrapper.find('.collapsible-line svg').classes()).toContain('ic-angle-down');
expect(findCollapsibleLine().contains('[data-testid="angle-down-icon"]')).toBe(true);
});
describe('on click header section', () => {
it('calls toggleCollapsibleLine', () => {
jest.spyOn(wrapper.vm, 'toggleCollapsibleLine');
wrapper.find('.collapsible-line').trigger('click');
findCollapsibleLine().trigger('click');
expect(wrapper.vm.toggleCollapsibleLine).toHaveBeenCalled();
});
......
......@@ -126,7 +126,7 @@ describe('Grouped code quality reports app', () => {
});
it('renders a help icon with more information', () => {
expect(findWidget().html()).toContain('ic-question');
expect(findWidget().contains('[data-testid="question-icon"]')).toBe(true);
});
});
......@@ -140,7 +140,7 @@ describe('Grouped code quality reports app', () => {
});
it('does not render a help icon', () => {
expect(findWidget().html()).not.toContain('ic-question');
expect(findWidget().contains('[data-testid="question-icon"]')).toBe(false);
});
});
});
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