Commit d3527803 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'refactor/spec-javascripts-commit-to-jest' into 'master'

Migrate spec/javascripts/commit/ to Jest

Closes #194222

See merge request gitlab-org/gitlab!26738
parents 5d19a180 fc5e1990
...@@ -156,7 +156,7 @@ export default { ...@@ -156,7 +156,7 @@ export default {
<gl-loading-icon <gl-loading-icon
v-if="isLoading" v-if="isLoading"
:label="s__('Pipelines|Loading Pipelines')" :label="s__('Pipelines|Loading Pipelines')"
:size="3" size="lg"
class="prepend-top-20" class="prepend-top-20"
/> />
......
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Api from '~/api'; import Api from '~/api';
import pipelinesTable from '~/commit/pipelines/pipelines_table.vue'; import pipelinesTable from '~/commit/pipelines/pipelines_table.vue';
describe('Pipelines table in Commits and Merge requests', function() { describe('Pipelines table in Commits and Merge requests', () => {
const jsonFixtureName = 'pipelines/pipelines.json'; const jsonFixtureName = 'pipelines/pipelines.json';
let pipeline; let pipeline;
let PipelinesTable; let PipelinesTable;
...@@ -37,19 +37,19 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -37,19 +37,19 @@ describe('Pipelines table in Commits and Merge requests', function() {
describe('successful request', () => { describe('successful request', () => {
describe('without pipelines', () => { describe('without pipelines', () => {
beforeEach(function() { beforeEach(() => {
mock.onGet('endpoint.json').reply(200, []); mock.onGet('endpoint.json').reply(200, []);
vm = mountComponent(PipelinesTable, props); vm = mountComponent(PipelinesTable, props);
}); });
it('should render the empty state', function(done) { it('should render the empty state', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.empty-state')).toBeDefined(); expect(vm.$el.querySelector('.empty-state')).toBeDefined();
expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null);
done(); done();
}, 0); });
}); });
}); });
...@@ -60,19 +60,19 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -60,19 +60,19 @@ describe('Pipelines table in Commits and Merge requests', function() {
}); });
it('should render a table with the received pipelines', done => { it('should render a table with the received pipelines', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelectorAll('.ci-table .commit').length).toEqual(1); expect(vm.$el.querySelectorAll('.ci-table .commit').length).toEqual(1);
expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
expect(vm.$el.querySelector('.empty-state')).toBe(null); expect(vm.$el.querySelector('.empty-state')).toBe(null);
expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null);
done(); done();
}, 0); });
}); });
describe('with pagination', () => { describe('with pagination', () => {
it('should make an API request when using pagination', done => { it('should make an API request when using pagination', done => {
setTimeout(() => { setImmediate(() => {
spyOn(vm, 'updateContent'); jest.spyOn(vm, 'updateContent').mockImplementation(() => {});
vm.store.state.pageInfo = { vm.store.state.pageInfo = {
page: 1, page: 1,
...@@ -135,7 +135,7 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -135,7 +135,7 @@ describe('Pipelines table in Commits and Merge requests', function() {
}), }),
); );
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).not.toBeNull(); expect(vm.$el.querySelector('.js-run-mr-pipeline')).not.toBeNull();
done(); done();
}); });
...@@ -156,7 +156,7 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -156,7 +156,7 @@ describe('Pipelines table in Commits and Merge requests', function() {
}), }),
); );
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
done(); done();
}); });
...@@ -177,7 +177,7 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -177,7 +177,7 @@ describe('Pipelines table in Commits and Merge requests', function() {
}), }),
); );
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
done(); done();
}); });
...@@ -198,7 +198,7 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -198,7 +198,7 @@ describe('Pipelines table in Commits and Merge requests', function() {
}), }),
); );
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
done(); done();
}); });
...@@ -222,15 +222,15 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -222,15 +222,15 @@ describe('Pipelines table in Commits and Merge requests', function() {
}); });
it('updates the loading state', done => { it('updates the loading state', done => {
spyOn(Api, 'postMergeRequestPipeline').and.returnValue(Promise.resolve()); jest.spyOn(Api, 'postMergeRequestPipeline').mockReturnValue(Promise.resolve());
setTimeout(() => { setImmediate(() => {
vm.$el.querySelector('.js-run-mr-pipeline').click(); vm.$el.querySelector('.js-run-mr-pipeline').click();
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.state.isRunningMergeRequestPipeline).toBe(true); expect(vm.state.isRunningMergeRequestPipeline).toBe(true);
setTimeout(() => { setImmediate(() => {
expect(vm.state.isRunningMergeRequestPipeline).toBe(false); expect(vm.state.isRunningMergeRequestPipeline).toBe(false);
done(); done();
...@@ -248,14 +248,14 @@ describe('Pipelines table in Commits and Merge requests', function() { ...@@ -248,14 +248,14 @@ describe('Pipelines table in Commits and Merge requests', function() {
vm = mountComponent(PipelinesTable, props); vm = mountComponent(PipelinesTable, props);
}); });
it('should render error state', function(done) { it('should render error state', done => {
setTimeout(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
expect(vm.$el.querySelector('.js-empty-state')).toBe(null); expect(vm.$el.querySelector('.js-empty-state')).toBe(null);
expect(vm.$el.querySelector('.ci-table')).toBe(null); expect(vm.$el.querySelector('.ci-table')).toBe(null);
done(); done();
}, 0); });
}); });
}); });
}); });
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