Commit 90945024 authored by Himanshu Kapoor's avatar Himanshu Kapoor

Migrate reports to Jest

Migrate spec/javascripts/reports tests to Jest
parent ea307cd5
...@@ -35,7 +35,7 @@ describe('Grouped Test Reports App', () => { ...@@ -35,7 +35,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders success summary text', done => { it('renders success summary text', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary contained no changed test results out of 11 total tests', 'Test summary contained no changed test results out of 11 total tests',
...@@ -49,7 +49,7 @@ describe('Grouped Test Reports App', () => { ...@@ -49,7 +49,7 @@ describe('Grouped Test Reports App', () => {
'java ant found no changed test results out of 3 total tests', 'java ant found no changed test results out of 3 total tests',
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -62,14 +62,14 @@ describe('Grouped Test Reports App', () => { ...@@ -62,14 +62,14 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders success summary text', done => { it('renders success summary text', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).not.toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).not.toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary results are being parsed', 'Test summary results are being parsed',
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -82,7 +82,7 @@ describe('Grouped Test Reports App', () => { ...@@ -82,7 +82,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders failed summary text + new badge', done => { it('renders failed summary text + new badge', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary contained 2 failed out of 11 total tests', 'Test summary contained 2 failed out of 11 total tests',
...@@ -95,7 +95,7 @@ describe('Grouped Test Reports App', () => { ...@@ -95,7 +95,7 @@ describe('Grouped Test Reports App', () => {
'java ant found no changed test results out of 3 total tests', 'java ant found no changed test results out of 3 total tests',
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -108,7 +108,7 @@ describe('Grouped Test Reports App', () => { ...@@ -108,7 +108,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders error summary text + new badge', done => { it('renders error summary text + new badge', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary contained 2 errors out of 11 total tests', 'Test summary contained 2 errors out of 11 total tests',
...@@ -121,7 +121,7 @@ describe('Grouped Test Reports App', () => { ...@@ -121,7 +121,7 @@ describe('Grouped Test Reports App', () => {
'rspec:pg found no changed test results out of 8 total tests', 'rspec:pg found no changed test results out of 8 total tests',
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -134,7 +134,7 @@ describe('Grouped Test Reports App', () => { ...@@ -134,7 +134,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders summary text', done => { it('renders summary text', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary contained 2 failed and 2 fixed test results out of 11 total tests', 'Test summary contained 2 failed and 2 fixed test results out of 11 total tests',
...@@ -147,7 +147,7 @@ describe('Grouped Test Reports App', () => { ...@@ -147,7 +147,7 @@ describe('Grouped Test Reports App', () => {
expect(vm.$el.textContent).toContain('New'); expect(vm.$el.textContent).toContain('New');
expect(vm.$el.textContent).toContain(' java ant found 1 failed out of 3 total tests'); expect(vm.$el.textContent).toContain(' java ant found 1 failed out of 3 total tests');
done(); done();
}, 0); });
}); });
}); });
...@@ -160,7 +160,7 @@ describe('Grouped Test Reports App', () => { ...@@ -160,7 +160,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders summary text', done => { it('renders summary text', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull(); expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary contained 4 fixed test results out of 11 total tests', 'Test summary contained 4 fixed test results out of 11 total tests',
...@@ -170,11 +170,11 @@ describe('Grouped Test Reports App', () => { ...@@ -170,11 +170,11 @@ describe('Grouped Test Reports App', () => {
'rspec:pg found 4 fixed test results out of 8 total tests', 'rspec:pg found 4 fixed test results out of 8 total tests',
); );
done(); done();
}, 0); });
}); });
it('renders resolved failures', done => { it('renders resolved failures', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.report-block-container').textContent).toContain( expect(vm.$el.querySelector('.report-block-container').textContent).toContain(
resolvedFailures.suites[0].resolved_failures[0].name, resolvedFailures.suites[0].resolved_failures[0].name,
); );
...@@ -183,11 +183,11 @@ describe('Grouped Test Reports App', () => { ...@@ -183,11 +183,11 @@ describe('Grouped Test Reports App', () => {
resolvedFailures.suites[0].resolved_failures[1].name, resolvedFailures.suites[0].resolved_failures[1].name,
); );
done(); done();
}, 0); });
}); });
it('renders resolved errors', done => { it('renders resolved errors', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.report-block-container').textContent).toContain( expect(vm.$el.querySelector('.report-block-container').textContent).toContain(
resolvedFailures.suites[0].resolved_errors[0].name, resolvedFailures.suites[0].resolved_errors[0].name,
); );
...@@ -196,7 +196,7 @@ describe('Grouped Test Reports App', () => { ...@@ -196,7 +196,7 @@ describe('Grouped Test Reports App', () => {
resolvedFailures.suites[0].resolved_errors[1].name, resolvedFailures.suites[0].resolved_errors[1].name,
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -209,7 +209,7 @@ describe('Grouped Test Reports App', () => { ...@@ -209,7 +209,7 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders an error status for the report', done => { it('renders an error status for the report', done => {
setTimeout(() => { setImmediate(() => {
const { name } = failedReport.suites[0]; const { name } = failedReport.suites[0];
expect(vm.$el.querySelector('.report-block-list-issue').textContent).toContain( expect(vm.$el.querySelector('.report-block-list-issue').textContent).toContain(
...@@ -229,12 +229,12 @@ describe('Grouped Test Reports App', () => { ...@@ -229,12 +229,12 @@ describe('Grouped Test Reports App', () => {
}); });
it('renders loading summary text with loading icon', done => { it('renders loading summary text with loading icon', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual( expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Test summary failed loading results', 'Test summary failed loading results',
); );
done(); done();
}, 0); });
}); });
}); });
...@@ -252,9 +252,9 @@ describe('Grouped Test Reports App', () => { ...@@ -252,9 +252,9 @@ describe('Grouped Test Reports App', () => {
'Test summary results are being parsed', 'Test summary results are being parsed',
); );
setTimeout(() => { setImmediate(() => {
done(); done();
}, 0); });
}); });
}); });
}); });
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import component from '~/reports/components/modal_open_name.vue'; import component from '~/reports/components/modal_open_name.vue';
Vue.use(Vuex); Vue.use(Vuex);
...@@ -38,7 +38,7 @@ describe('Modal open name', () => { ...@@ -38,7 +38,7 @@ describe('Modal open name', () => {
}); });
it('calls openModal actions when button is clicked', () => { it('calls openModal actions when button is clicked', () => {
spyOn(vm, 'openModal'); jest.spyOn(vm, 'openModal').mockImplementation(() => {});
vm.$el.click(); vm.$el.click();
......
import Vue from 'vue'; import Vue from 'vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import component from '~/reports/components/summary_row.vue'; import component from '~/reports/components/summary_row.vue';
describe('Summary row', () => { describe('Summary row', () => {
......
...@@ -26,7 +26,7 @@ describe('Test Issue body', () => { ...@@ -26,7 +26,7 @@ describe('Test Issue body', () => {
props: commonProps, props: commonProps,
}); });
spyOn(vm, 'openModal'); jest.spyOn(vm, 'openModal').mockImplementation(() => {});
vm.$el.querySelector('button').click(); vm.$el.querySelector('button').click();
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'spec/helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { import {
setEndpoint, setEndpoint,
......
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