Skip to content

Commit

Permalink
test: Use short syntax for queries and mutations (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Mar 19, 2021
1 parent 8c9c7d6 commit b8efdbb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/__tests__/starWarsConnectionTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StarWarsSchema as schema } from './starWarsSchema';
describe('Star Wars connections', () => {
it('fetches the first ship of the rebels', () => {
const source = `
query RebelsShipsQuery {
{
rebels {
name,
ships(first: 1) {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('Star Wars connections', () => {

it('fetches the first two ships of the rebels with a cursor', () => {
const source = `
query MoreRebelShipsQuery {
{
rebels {
name,
ships(first: 2) {
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Star Wars connections', () => {

it('fetches the next three ships of the rebels with a cursor', () => {
const source = `
query EndOfRebelShipsQuery {
{
rebels {
name,
ships(first: 3 after: "YXJyYXljb25uZWN0aW9uOjE=") {
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('Star Wars connections', () => {

it('fetches no ships of the rebels at the end of connection', () => {
const source = `
query RebelsQuery {
{
rebels {
name,
ships(first: 3 after: "YXJyYXljb25uZWN0aW9uOjQ=") {
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('Star Wars connections', () => {

it('identifies the end of the list', () => {
const source = `
query EndOfRebelShipsQuery {
{
rebels {
name,
originalShips: ships(first: 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/starWarsMutationTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StarWarsSchema as schema } from './starWarsSchema';
describe('Star Wars mutations', () => {
it('mutates the data set', () => {
const source = `
mutation AddBWingQuery($input: IntroduceShipInput!) {
mutation ($input: IntroduceShipInput!) {
introduceShip(input: $input) {
ship {
id
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/starWarsObjectIdentificationTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StarWarsSchema as schema } from './starWarsSchema';
describe('Star Wars object identification', () => {
it('fetches the ID and name of the rebels', () => {
const source = `
query RebelsQuery {
{
rebels {
id
name
Expand All @@ -27,7 +27,7 @@ describe('Star Wars object identification', () => {

it('refetches the rebels', () => {
const source = `
query RebelsRefetchQuery {
{
node(id: "RmFjdGlvbjox") {
id
... on Faction {
Expand All @@ -49,7 +49,7 @@ describe('Star Wars object identification', () => {

it('fetches the ID and name of the empire', () => {
const source = `
query EmpireQuery {
{
empire {
id
name
Expand All @@ -66,7 +66,7 @@ describe('Star Wars object identification', () => {

it('refetches the empire', () => {
const source = `
query EmpireRefetchQuery {
{
node(id: "RmFjdGlvbjoy") {
id
... on Faction {
Expand All @@ -85,7 +85,7 @@ describe('Star Wars object identification', () => {

it('refetches the X-Wing', () => {
const source = `
query XWingRefetchQuery {
{
node(id: "U2hpcDox") {
id
... on Ship {
Expand Down
4 changes: 2 additions & 2 deletions src/connection/__tests__/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const schema = new GraphQLSchema({
describe('connectionDefinition()', () => {
it('includes connection and edge fields', () => {
const source = `
query FriendsQuery {
{
user {
friends(first: 2) {
totalCount
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('connectionDefinition()', () => {

it('works with backwardConnectionArgs', () => {
const source = `
query FriendsQuery {
{
user {
friendsBackward(last: 2) {
edges {
Expand Down
12 changes: 6 additions & 6 deletions src/mutation/__tests__/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const schema = new GraphQLSchema({
describe('mutationWithClientMutationId()', () => {
it('requires an argument', () => {
const source = `
mutation M {
mutation {
simpleMutation {
result
}
Expand All @@ -134,7 +134,7 @@ describe('mutationWithClientMutationId()', () => {

it('returns the same client mutation ID', () => {
const source = `
mutation M {
mutation {
simpleMutation(input: {clientMutationId: "abc"}) {
result
clientMutationId
Expand All @@ -154,7 +154,7 @@ describe('mutationWithClientMutationId()', () => {

it('supports thunks as input and output fields', () => {
const source = `
mutation M {
mutation {
simpleMutationWithThunkFields(input: {
inputData: 1234,
clientMutationId: "abc"
Expand All @@ -177,7 +177,7 @@ describe('mutationWithClientMutationId()', () => {

it('supports promise mutations', async () => {
const source = `
mutation M {
mutation {
simplePromiseMutation(input: {clientMutationId: "abc"}) {
result
clientMutationId
Expand All @@ -197,7 +197,7 @@ describe('mutationWithClientMutationId()', () => {

it('can access rootValue', () => {
const source = `
mutation M {
mutation {
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
result
clientMutationId
Expand All @@ -218,7 +218,7 @@ describe('mutationWithClientMutationId()', () => {

it('supports mutations returning null', () => {
const source = `
mutation M {
mutation {
simpleRootValueMutation(input: {clientMutationId: "abc"}) {
result
clientMutationId
Expand Down

0 comments on commit b8efdbb

Please sign in to comment.