summaryrefslogtreecommitdiff
path: root/spec/frontend/pipeline_editor/graphql/resolvers_spec.js
blob: 90acdf3ec0b2dedf82afb5fa000ed5157179cc4d (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
39
40
41
42
import Api from '~/api';
import { mockProjectPath, mockDefaultBranch, mockCiConfigPath, mockCiYml } from '../mock_data';

import { resolvers } from '~/pipeline_editor/graphql/resolvers';

jest.mock('~/api', () => {
  return {
    getRawFile: jest.fn(),
  };
});

describe('~/pipeline_editor/graphql/resolvers', () => {
  describe('Query', () => {
    describe('blobContent', () => {
      beforeEach(() => {
        Api.getRawFile.mockResolvedValue({
          data: mockCiYml,
        });
      });

      afterEach(() => {
        Api.getRawFile.mockReset();
      });

      it('resolves lint data with type names', async () => {
        const result = resolvers.Query.blobContent(null, {
          projectPath: mockProjectPath,
          path: mockCiConfigPath,
          ref: mockDefaultBranch,
        });

        expect(Api.getRawFile).toHaveBeenCalledWith(mockProjectPath, mockCiConfigPath, {
          ref: mockDefaultBranch,
        });

        // eslint-disable-next-line no-underscore-dangle
        expect(result.__typename).toBe('BlobContent');
        await expect(result.rawData).resolves.toBe(mockCiYml);
      });
    });
  });
});