@@ -76,12 +76,12 @@ describe('VuexORMApollo', () => {
7676
7777 store . dispatch ( 'entities/users/insert' , { data : { id : 1 , name : 'Charlie Brown' } } ) ;
7878 store . dispatch ( 'entities/users/insert' , { data : { id : 2 , name : 'Peppermint Patty' } } ) ;
79- store . dispatch ( 'entities/posts/insert' , { data : { id : 1 , userId : 1 , title : 'Example post 1' , content : 'Foo' } } ) ;
80- store . dispatch ( 'entities/posts/insert' , { data : { id : 1 , userId : 1 , title : 'Example post 2' , content : 'Bar' } } ) ;
81- store . dispatch ( 'entities/videos/insert' , { data : { id : 1 , userId : 1 , title : 'Example video' , content : 'Video' } } ) ;
79+ store . dispatch ( 'entities/posts/insert' , { data : { id : 1 , otherId : 9 , userId : 1 , title : 'Example post 1' , content : 'Foo' } } ) ;
80+ store . dispatch ( 'entities/posts/insert' , { data : { id : 2 , otherId : 10 , userId : 1 , title : 'Example post 2' , content : 'Bar' } } ) ;
81+ store . dispatch ( 'entities/videos/insert' , { data : { id : 1 , otherId : 11 , userId : 1 , title : 'Example video' , content : 'Video' } } ) ;
8282 store . dispatch ( 'entities/comments/insert' , { data : { id : 1 , userId : 1 , subjectId : 1 , subjectType : 'videos' , content : 'Example comment 1' } } ) ;
83- store . dispatch ( 'entities/comments/insert' , { data : { id : 1 , userId : 2 , subjectId : 1 , subjectType : 'posts' , content : 'Example comment 2' } } ) ;
84- store . dispatch ( 'entities/comments/insert' , { data : { id : 1 , userId : 2 , subjectId : 2 , subjectType : 'posts' , content : 'Example comment 3' } } ) ;
83+ store . dispatch ( 'entities/comments/insert' , { data : { id : 2 , userId : 2 , subjectId : 1 , subjectType : 'posts' , content : 'Example comment 2' } } ) ;
84+ store . dispatch ( 'entities/comments/insert' , { data : { id : 3 , userId : 2 , subjectId : 2 , subjectType : 'posts' , content : 'Example comment 3' } } ) ;
8585 } ) ;
8686
8787 describe ( 'fetch' , ( ) => {
@@ -288,24 +288,72 @@ query Users {
288288 it ( 'sends the correct query to the API' , async ( ) => {
289289 const response = {
290290 data : {
291- createUser : {
292- __typename : 'user' ,
293- id : 1 ,
294- name : 'Charlie Brown'
291+ createPost : {
292+ __typename : 'post' ,
293+ id : 42 ,
294+ otherId : 13548 ,
295+ title : 'Example post 1' ,
296+ content : 'Foo' ,
297+ comments : {
298+ __typename : 'comment' ,
299+ nodes : [ {
300+ __typename : 'comment' ,
301+ id : 15 ,
302+ content : 'Works!' ,
303+ subjectId : 42 ,
304+ subjectType : 'Post'
305+ } ]
306+ } ,
307+ user : {
308+ __typename : 'user' ,
309+ id : 1 ,
310+ name : 'Charlie Brown' ,
311+ }
295312 }
296313 }
297314 } ;
298315
299316 const request = await sendWithMockFetch ( response , async ( ) => {
300- await store . dispatch ( 'entities/users /persist' , { id : 1 } ) ;
317+ await store . dispatch ( 'entities/posts /persist' , { id : 1 } ) ;
301318 } ) ;
302319
303- expect ( request . variables ) . toEqual ( { user : { id : 1 , name : 'Charlie Brown' } } ) ;
320+ expect ( request . variables ) . toEqual ( {
321+ post : {
322+ content : "Foo" ,
323+ id : 1 ,
324+ otherId : 9 ,
325+ title : "Example post 1" ,
326+ userId : 1 ,
327+ user : {
328+ id : 1 ,
329+ name : 'Charlie Brown'
330+ }
331+ }
332+ } ) ;
333+
334+
304335 expect ( request . query ) . toEqual ( `
305- mutation CreateUser($user: UserInput !) {
306- createUser(user : $user ) {
336+ mutation CreatePost($post: PostInput !) {
337+ createPost(post : $post ) {
307338 id
308- name
339+ content
340+ title
341+ otherId
342+ user {
343+ id
344+ name
345+ __typename
346+ }
347+ comments {
348+ nodes {
349+ id
350+ content
351+ subjectId
352+ subjectType
353+ __typename
354+ }
355+ __typename
356+ }
309357 __typename
310358 }
311359}
0 commit comments