diff options
Diffstat (limited to 'spec/frontend/pipeline_editor/graphql/resolvers_spec.js')
-rw-r--r-- | spec/frontend/pipeline_editor/graphql/resolvers_spec.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/frontend/pipeline_editor/graphql/resolvers_spec.js b/spec/frontend/pipeline_editor/graphql/resolvers_spec.js new file mode 100644 index 00000000000..90acdf3ec0b --- /dev/null +++ b/spec/frontend/pipeline_editor/graphql/resolvers_spec.js @@ -0,0 +1,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); + }); + }); + }); +}); |