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', () => { ...@@ -32,7 +32,7 @@ describe('ItemTypeIconComponent', () => {
vm = createComponent(ITEM_TYPE.GROUP); 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(); vm.$destroy();
}); });
......
...@@ -23,7 +23,7 @@ describe('NavDropdown', () => { ...@@ -23,7 +23,7 @@ describe('NavDropdown', () => {
vm.$mount(); 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 findMRIcon = () => findIcon('merge-request');
const findBranchIcon = () => findIcon('branch'); const findBranchIcon = () => findIcon('branch');
......
...@@ -39,7 +39,7 @@ describe('IDE NavDropdown', () => { ...@@ -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 findMRIcon = () => findIcon('merge-request');
const findNavForm = () => wrapper.find('.ide-nav-form'); const findNavForm = () => wrapper.find('.ide-nav-form');
const showDropdown = () => { const showDropdown = () => {
......
...@@ -42,6 +42,8 @@ describe('Job Log', () => { ...@@ -42,6 +42,8 @@ describe('Job Log', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findCollapsibleLine = () => wrapper.find('.collapsible-line');
describe('line numbers', () => { describe('line numbers', () => {
it('renders a line number for each open line', () => { it('renders a line number for each open line', () => {
expect(wrapper.find('#L1').text()).toBe('1'); expect(wrapper.find('#L1').text()).toBe('1');
...@@ -56,18 +58,18 @@ describe('Job Log', () => { ...@@ -56,18 +58,18 @@ describe('Job Log', () => {
describe('collapsible sections', () => { describe('collapsible sections', () => {
it('renders a clickable header section', () => { 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', () => { 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', () => { describe('on click header section', () => {
it('calls toggleCollapsibleLine', () => { it('calls toggleCollapsibleLine', () => {
jest.spyOn(wrapper.vm, 'toggleCollapsibleLine'); jest.spyOn(wrapper.vm, 'toggleCollapsibleLine');
wrapper.find('.collapsible-line').trigger('click'); findCollapsibleLine().trigger('click');
expect(wrapper.vm.toggleCollapsibleLine).toHaveBeenCalled(); expect(wrapper.vm.toggleCollapsibleLine).toHaveBeenCalled();
}); });
......
...@@ -126,7 +126,7 @@ describe('Grouped code quality reports app', () => { ...@@ -126,7 +126,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('renders a help icon with more information', () => { 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', () => { ...@@ -140,7 +140,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('does not render a help icon', () => { 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