Welcome to mirror list, hosted at ThFree Co, Russian Federation.

submit_content_changes_spec.js « resolvers « graphql « static_site_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a0529f5f945325134b1baca15ab2232806043f64 (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
import savedContentMetaQuery from '~/static_site_editor/graphql/queries/saved_content_meta.query.graphql';
import submitContentChangesResolver from '~/static_site_editor/graphql/resolvers/submit_content_changes';
import submitContentChanges from '~/static_site_editor/services/submit_content_changes';

import {
  projectId as project,
  sourcePath,
  username,
  sourceContentYAML as content,
  savedContentMeta,
} from '../../mock_data';

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

describe('static_site_editor/graphql/resolvers/submit_content_changes', () => {
  it('writes savedContentMeta query with the data returned by the submitContentChanges service', () => {
    const cache = { writeQuery: jest.fn() };

    submitContentChanges.mockResolvedValueOnce(savedContentMeta);

    return submitContentChangesResolver(
      {},
      { input: { path: sourcePath, project, sourcePath, content, username } },
      { cache },
    ).then(() => {
      expect(cache.writeQuery).toHaveBeenCalledWith({
        query: savedContentMetaQuery,
        data: {
          savedContentMeta: {
            __typename: 'SavedContentMeta',
            ...savedContentMeta,
          },
        },
      });
    });
  });
});