summaryrefslogtreecommitdiff
path: root/spec/frontend/static_site_editor/graphql/resolvers/has_submitted_changes_spec.js
blob: 0670b240a3f9ec0704c9ebcaf49e83e6c0dff0c9 (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
import appDataQuery from '~/static_site_editor/graphql/queries/app_data.query.graphql';
import hasSubmittedChanges from '~/static_site_editor/graphql/resolvers/has_submitted_changes';

describe('static_site_editor/graphql/resolvers/has_submitted_changes', () => {
  it('updates the cache with the data passed in input', () => {
    const cachedData = { appData: { original: 'foo' } };
    const newValue = { input: { hasSubmittedChanges: true } };

    const cache = {
      readQuery: jest.fn().mockReturnValue(cachedData),
      writeQuery: jest.fn(),
    };
    hasSubmittedChanges(null, newValue, { cache });

    expect(cache.readQuery).toHaveBeenCalledWith({ query: appDataQuery });
    expect(cache.writeQuery).toHaveBeenCalledWith({
      query: appDataQuery,
      data: {
        appData: {
          __typename: 'AppData',
          original: 'foo',
          hasSubmittedChanges: true,
        },
      },
    });
  });
});