summaryrefslogtreecommitdiff
path: root/spec/frontend/ci_lint/graphql/resolvers_spec.js
blob: 437c52cf6b40adc3d1147914d11582b2f0082931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status';

import resolvers from '~/ci_lint/graphql/resolvers';
import { mockLintResponse } from '../mock_data';

describe('~/ci_lint/graphql/resolvers', () => {
  let mock;

  beforeEach(() => {
    mock = new MockAdapter(axios);
  });

  afterEach(() => {
    mock.restore();
  });

  describe('Mutation', () => {
    describe('lintCI', () => {
      const endpoint = '/ci/lint';

      beforeEach(() => {
        mock.onPost(endpoint).reply(httpStatus.OK, mockLintResponse);
      });

      it('resolves lint data with type names', async () => {
        const result = resolvers.Mutation.lintCI(null, {
          endpoint,
          content: 'content',
          dry_run: true,
        });

        await expect(result).resolves.toMatchSnapshot();
      });
    });
  });
});