summaryrefslogtreecommitdiff
path: root/spec/frontend/static_site_editor/graphql/resolvers/file_spec.js
blob: 83ad23f7dcf5aed12a66f4ab79ee4ed0ee2d6b04 (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
import fileResolver from '~/static_site_editor/graphql/resolvers/file';
import loadSourceContent from '~/static_site_editor/services/load_source_content';

import {
  projectId,
  sourcePath,
  sourceContentTitle as title,
  sourceContentYAML as content,
} from '../../mock_data';

jest.mock('~/static_site_editor/services/load_source_content', () => jest.fn());

describe('static_site_editor/graphql/resolvers/file', () => {
  it('returns file content and title when fetching file successfully', () => {
    loadSourceContent.mockResolvedValueOnce({ title, content });

    return fileResolver({ fullPath: projectId }, { path: sourcePath }).then((file) => {
      expect(file).toEqual({
        __typename: 'File',
        title,
        content,
      });
    });
  });
});