Skip to content

Commit

Permalink
Revert changes to graphcache/src/test-utils/
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jul 19, 2023
1 parent c90838b commit 6d1bb6d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
30 changes: 15 additions & 15 deletions exchanges/graphcache/src/test-utils/examples-1.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDocument, gql } from '@urql/core';
import { gql } from '@urql/core';
import { it, expect, afterEach } from 'vitest';
import { __initAnd_query as query } from '../operations/query';
import {
Expand All @@ -9,7 +9,7 @@ import * as InMemoryData from '../store/data';
import { Store } from '../store/store';
import { Data } from '../types';

const Todos = formatDocument(gql`
const Todos = gql`
query {
__typename
todos {
Expand All @@ -19,18 +19,18 @@ const Todos = formatDocument(gql`
text
}
}
`);
`;

const TodoFragment = formatDocument(gql`
const TodoFragment = gql`
fragment _ on Todo {
__typename
id
text
complete
}
`);
`;

const Todo = formatDocument(gql`
const Todo = gql`
query ($id: ID!) {
__typename
todo(id: $id) {
Expand All @@ -39,9 +39,9 @@ const Todo = formatDocument(gql`
complete
}
}
`);
`;

const ToggleTodo = formatDocument(gql`
const ToggleTodo = gql`
mutation ($id: ID!) {
__typename
toggleTodo(id: $id) {
Expand All @@ -51,9 +51,9 @@ const ToggleTodo = formatDocument(gql`
complete
}
}
`);
`;

const NestedClearNameTodo = formatDocument(gql`
const NestedClearNameTodo = gql`
mutation ($id: ID!) {
__typename
clearName(id: $id) {
Expand All @@ -66,7 +66,7 @@ const NestedClearNameTodo = formatDocument(gql`
}
}
}
`);
`;

afterEach(() => {
expect(console.warn).not.toHaveBeenCalled();
Expand Down Expand Up @@ -150,25 +150,25 @@ it('passes the "getting-started" example', () => {
it('resolves missing, nullable arguments on fields', () => {
const store = new Store();

const GetWithVariables = formatDocument(gql`
const GetWithVariables = gql`
query {
__typename
todo(first: null) {
__typename
id
}
}
`);
`;

const GetWithoutVariables = formatDocument(gql`
const GetWithoutVariables = gql`
query {
__typename
todo {
__typename
id
}
}
`);
`;

const dataToWrite = {
__typename: 'Query',
Expand Down
14 changes: 7 additions & 7 deletions exchanges/graphcache/src/test-utils/examples-2.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { formatDocument, gql } from '@urql/core';
import { gql } from '@urql/core';
import { it, afterEach, expect } from 'vitest';
import { __initAnd_query as query } from '../operations/query';
import { __initAnd_write as write } from '../operations/write';
import { Store } from '../store/store';

const Item = formatDocument(gql`
const Item = gql`
{
todo {
__typename
Expand All @@ -13,9 +13,9 @@ const Item = formatDocument(gql`
text
}
}
`);
`;

const ItemDetailed = formatDocument(gql`
const ItemDetailed = gql`
{
todo {
__typename
Expand All @@ -29,9 +29,9 @@ const ItemDetailed = formatDocument(gql`
}
}
}
`);
`;

const Pagination = formatDocument(gql`
const Pagination = gql`
query {
todos {
__typename
Expand All @@ -51,7 +51,7 @@ const Pagination = formatDocument(gql`
}
}
}
`);
`;

afterEach(() => {
expect(console.warn).not.toHaveBeenCalled();
Expand Down
10 changes: 5 additions & 5 deletions exchanges/graphcache/src/test-utils/examples-3.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDocument, gql } from '@urql/core';
import { gql } from '@urql/core';
import { it, afterEach, expect } from 'vitest';
import { __initAnd_query as query } from '../operations/query';
import { __initAnd_write as write } from '../operations/write';
Expand All @@ -10,20 +10,20 @@ afterEach(() => {

it('allows viewer fields to overwrite the root Query data', () => {
const store = new Store();
const get = formatDocument(gql`
const get = gql`
{
int
}
`);
const set = formatDocument(gql`
`;
const set = gql`
mutation {
mutate {
viewer {
int
}
}
}
`);
`;

write(
store,
Expand Down
7 changes: 2 additions & 5 deletions exchanges/graphcache/src/test-utils/suite.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocumentNode } from 'graphql';
import { formatDocument, gql } from '@urql/core';
import { gql } from '@urql/core';
import { it, expect } from 'vitest';
import { __initAnd_query as query } from '../operations/query';
import { __initAnd_write as write } from '../operations/write';
Expand All @@ -13,10 +13,7 @@ interface TestCase {

const expectCacheIntegrity = (testcase: TestCase) => {
const store = new Store();
const request = {
query: formatDocument(testcase.query),
variables: testcase.variables,
};
const request = { query: testcase.query, variables: testcase.variables };
const writeRes = write(store, request, testcase.data);
const queryRes = query(store, request);
expect(queryRes.data).not.toBe(null);
Expand Down

0 comments on commit 6d1bb6d

Please sign in to comment.