11/* @flow */
22
3- import { expect } from 'chai' ;
43import { TypeComposer , graphql } from 'graphql-compose' ;
54import { composeWithRelay } from '../composeWithRelay' ;
65import { userTypeComposer } from '../__mocks__/userTypeComposer' ;
@@ -17,44 +16,45 @@ describe('composeWithRelay', () => {
1716
1817 describe ( 'basic checks' , ( ) => {
1918 it ( 'should return TypeComposer' , ( ) => {
20- expect ( userComposer ) . instanceof ( TypeComposer ) ;
19+ expect ( userComposer ) . toBeInstanceOf ( TypeComposer ) ;
2120 } ) ;
2221
2322 it ( 'should throw error if got a not TypeComposer' , ( ) => {
24- expect ( ( ) => composeWithRelay ( 123 ) ) . to . throw ( 'should provide TypeComposer instance' ) ;
23+ expect ( ( ) => composeWithRelay ( 123 ) ) . toThrowError ( 'should provide TypeComposer instance' ) ;
2524 } ) ;
2625
2726 it ( 'should throw error if TypeComposer without recordIdFn' , ( ) => {
2827 const tc = userTypeComposer . clone ( 'AnotherUserType2' ) ;
2928 delete tc . gqType . _gqcGetRecordIdFn ;
30- expect ( ( ) => composeWithRelay ( tc ) ) . to . throw ( 'should have recordIdFn' ) ;
29+ expect ( ( ) => composeWithRelay ( tc ) ) . toThrowError ( 'should have recordIdFn' ) ;
3130 } ) ;
3231
3332 it ( 'should thow error if typeComposer does not have findById resolver' , ( ) => {
3433 const tc = userTypeComposer . clone ( 'AnotherUserType' ) ;
3534 tc . removeResolver ( 'findById' ) ;
36- expect ( ( ) => composeWithRelay ( tc ) ) . to . throw ( "does not have resolver with name 'findById'" ) ;
35+ expect ( ( ) => composeWithRelay ( tc ) ) . toThrowError (
36+ "does not have resolver with name 'findById'"
37+ ) ;
3738 } ) ;
3839 } ) ;
3940
4041 describe ( 'when pass RootQuery type composer' , ( ) => {
4142 it ( 'should add `node` field to RootQuery' , ( ) => {
4243 const nodeField = rootQueryComposer . getField ( 'node' ) ;
43- expect ( nodeField ) . to . be . ok ;
44- expect ( nodeField ) . property ( 'type' ) . instanceof ( GraphQLInterfaceType ) ;
45- expect ( nodeField ) . nested . property ( 'type.name' ) . to . equal ( 'Node' ) ;
44+ expect ( nodeField . type ) . toBeInstanceOf ( GraphQLInterfaceType ) ;
45+ expect ( nodeField . type . name ) . toBe ( 'Node' ) ;
4646 } ) ;
4747 } ) ;
4848
4949 describe ( 'when pass User type composer (not RootQuery)' , ( ) => {
5050 it ( 'should add or override id field' , ( ) => {
5151 const idField = userComposer . getField ( 'id' ) ;
52- expect ( idField . description ) . to . contain ( 'globally unique ID' ) ;
52+ expect ( idField . description ) . toContain ( 'globally unique ID' ) ;
5353 } ) ;
5454
5555 it ( 'should make id field NonNull' , ( ) => {
5656 const idField = userComposer . getField ( 'id' ) ;
57- expect ( idField . type ) . instanceof ( GraphQLNonNull ) ;
57+ expect ( idField . type ) . toBeInstanceOf ( GraphQLNonNull ) ;
5858 } ) ;
5959
6060 it ( 'should resolve globalId in `user.id` field' , async ( ) => {
@@ -72,8 +72,8 @@ describe('composeWithRelay', () => {
7272 }
7373 }` ;
7474 const result = await graphql . graphql ( schema , query ) ;
75- expect ( result ) . nested . property ( ' data.user.id' ) . equal ( toGlobalId ( 'User' , 1 ) ) ;
76- expect ( result ) . nested . property ( ' data.user.name' ) . equal ( 'Pavel' ) ;
75+ expect ( result . data . user . id ) . toBe ( toGlobalId ( 'User' , 1 ) ) ;
76+ expect ( result . data . user . name ) . toBe ( 'Pavel' ) ;
7777 } ) ;
7878
7979 it ( 'should resolve globalId in `node.id` field' , async ( ) => {
@@ -94,8 +94,8 @@ describe('composeWithRelay', () => {
9494 name
9595 }` ;
9696 const result = await graphql . graphql ( schema , query ) ;
97- expect ( result ) . nested . property ( ' data.node.id' ) . equal ( toGlobalId ( 'User' , 1 ) ) ;
98- expect ( result ) . nested . property ( ' data.node.name' ) . equal ( 'Pavel' ) ;
97+ expect ( result . data . node . id ) . toBe ( toGlobalId ( 'User' , 1 ) ) ;
98+ expect ( result . data . node . name ) . toBe ( 'Pavel' ) ;
9999 } ) ;
100100
101101 it ( 'should passthru clientMutationId in mutations' , async ( ) => {
@@ -116,8 +116,8 @@ describe('composeWithRelay', () => {
116116 }
117117 }` ;
118118 const result = await graphql . graphql ( schema , query ) ;
119- expect ( result ) . nested . property ( ' data.createUser.record.name' ) . equal ( 'Ok' ) ;
120- expect ( result ) . nested . property ( ' data.createUser.clientMutationId' ) . equal ( '123' ) ;
119+ expect ( result . data . createUser . record . name ) . toBe ( 'Ok' ) ;
120+ expect ( result . data . createUser . clientMutationId ) . toBe ( '123' ) ;
121121 } ) ;
122122 } ) ;
123123} ) ;
0 commit comments