debian-mirror-gitlab/spec/frontend/pipeline_editor/graphql/resolvers_spec.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import MockAdapter from 'axios-mock-adapter';
2021-03-11 19:13:27 +05:30
import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status';
import { resolvers } from '~/pipeline_editor/graphql/resolvers';
2021-09-30 23:02:18 +05:30
import { mockLintResponse } from '../mock_data';
2021-01-29 00:20:46 +05:30
jest.mock('~/api', () => {
return {
getRawFile: jest.fn(),
};
});
describe('~/pipeline_editor/graphql/resolvers', () => {
2021-02-22 17:27:13 +05:30
describe('Mutation', () => {
describe('lintCI', () => {
let mock;
let result;
const endpoint = '/ci/lint';
beforeEach(async () => {
mock = new MockAdapter(axios);
mock.onPost(endpoint).reply(httpStatus.OK, mockLintResponse);
result = await resolvers.Mutation.lintCI(null, {
endpoint,
content: 'content',
dry_run: true,
});
});
afterEach(() => {
mock.restore();
});
/* eslint-disable no-underscore-dangle */
it('lint data has correct type names', async () => {
expect(result.__typename).toBe('CiLintContent');
expect(result.jobs[0].__typename).toBe('CiLintJob');
expect(result.jobs[1].__typename).toBe('CiLintJob');
expect(result.jobs[1].only.__typename).toBe('CiLintJobOnlyPolicy');
});
/* eslint-enable no-underscore-dangle */
it('lint data is as expected', () => {
expect(result).toMatchSnapshot();
});
});
});
2021-01-29 00:20:46 +05:30
});