File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ describe('kitsu', () => {
9999 expect ( request ) . toEqual ( getSingleWithIncludes . kitsu )
100100 } )
101101
102- it ( 'fetches relationships of a resource' , async ( ) => {
102+ it ( 'fetches : resource/:id/relationships/:relationship ' , async ( ) => {
103103 expect . assertions ( 1 )
104104 const response = {
105105 links : {
@@ -117,6 +117,20 @@ describe('kitsu', () => {
117117 expect ( request ) . toEqual ( response )
118118 } )
119119
120+ it ( 'fetches :resource/:relationship/:subRelationship' , async ( ) => {
121+ expect . assertions ( 1 )
122+ const response = {
123+ data : {
124+ type : 'profile' ,
125+ id : '1'
126+ }
127+ }
128+ const api = new Kitsu ( { pluralize : false } )
129+ mock . onGet ( 'profile/accounts/me' ) . reply ( 200 , response )
130+ const request = await api . get ( 'profile/accounts/me' )
131+ expect ( request ) . toEqual ( response )
132+ } )
133+
120134 it ( 'returns a JSON:API error object for invalid queries' , async ( ) => {
121135 expect . assertions ( 5 )
122136 const api = new Kitsu ( )
Original file line number Diff line number Diff line change @@ -213,9 +213,16 @@ export default class Kitsu {
213213 const params = merge ( { } , config . params )
214214 const [ res , id , relationship , subRelationship ] = model . split ( '/' )
215215
216+ // :resource
216217 let url = this . plural ( this . resCase ( res ) )
217- if ( id ) url += `/${ id } `
218+ // :resource/:id
219+ // :resource/:relationship
220+ if ( id ) url += `/${ this . resCase ( id ) } `
221+ // :resource/:id/:relationship
222+ // :resource/:relationship/:subRelationship
218223 if ( relationship ) url += `/${ this . resCase ( relationship ) } `
224+ // :resource/:id/relationships/:relationship
225+ // :resource/:id/:relationship/:subRelationship
219226 if ( subRelationship ) url += `/${ this . resCase ( subRelationship ) } `
220227
221228 const { data } = await this . axios . get ( url , {
You can’t perform that action at this time.
0 commit comments