@@ -108,10 +108,10 @@ describe('JsonApiDatastore', () => {
108108 backend . connections . subscribe ( ( c : MockConnection ) => {
109109 expect ( c . request . url ) . not . toEqual ( `${ BASE_URL } /${ API_VERSION } ` ) ;
110110 expect ( c . request . url ) . toEqual ( `${ BASE_URL } /${ API_VERSION } /` + 'authors?' +
111- encodeURIComponent ( 'page[size]' ) + '=10&' +
112- encodeURIComponent ( 'page[number]' ) + '=1&' +
113- encodeURIComponent ( 'include' ) + '=comments&' +
114- encodeURIComponent ( 'filter[title][keyword]' ) + '=Tolkien' ) ;
111+ encodeURIComponent ( 'page[size]' ) + '=10&' +
112+ encodeURIComponent ( 'page[number]' ) + '=1&' +
113+ encodeURIComponent ( 'include' ) + '=comments&' +
114+ encodeURIComponent ( 'filter[title][keyword]' ) + '=Tolkien' ) ;
115115 expect ( c . request . method ) . toEqual ( RequestMethod . Get ) ;
116116 } ) ;
117117 datastore . query ( Author , {
@@ -134,6 +134,7 @@ describe('JsonApiDatastore', () => {
134134 expect ( c . request . headers . has ( 'Authorization' ) ) . toBeTruthy ( ) ;
135135 expect ( c . request . headers . get ( 'Authorization' ) ) . toBe ( 'Bearer' ) ;
136136 } ) ;
137+
137138 datastore . query ( Author , null , new Headers ( { Authorization : 'Bearer' } ) ) . subscribe ( ) ;
138139 } ) ;
139140
@@ -212,11 +213,13 @@ describe('JsonApiDatastore', () => {
212213
213214 it ( 'should fire error' , ( ) => {
214215 const resp = {
215- errors : [ {
216- code : '100' ,
217- title : 'Example error' ,
218- detail : 'detailed error Message'
219- } ]
216+ errors : [
217+ {
218+ code : '100' ,
219+ title : 'Example error' ,
220+ detail : 'detailed error Message'
221+ }
222+ ]
220223 } ;
221224
222225 backend . connections . subscribe ( ( c : MockConnection ) => {
@@ -227,15 +230,13 @@ describe('JsonApiDatastore', () => {
227230 } )
228231 ) ) ;
229232 } ) ;
230- datastore . query ( Author ) . subscribe ( ( authors ) => fail ( 'onNext has been called' ) ,
231- ( response ) => {
232- expect ( response ) . toEqual ( jasmine . any ( ErrorResponse ) ) ;
233- expect ( response . errors . length ) . toEqual ( 1 ) ;
234- expect ( response . errors [ 0 ] . code ) . toEqual ( resp . errors [ 0 ] . code ) ;
235- expect ( response . errors [ 0 ] . title ) . toEqual ( resp . errors [ 0 ] . title ) ;
236- expect ( response . errors [ 0 ] . detail ) . toEqual ( resp . errors [ 0 ] . detail ) ;
237- } ,
238- ( ) => fail ( 'onCompleted has been called' ) ) ;
233+ datastore . query ( Author ) . subscribe ( ( authors ) => fail ( 'onNext has been called' ) , ( response ) => {
234+ expect ( response ) . toEqual ( jasmine . any ( ErrorResponse ) ) ;
235+ expect ( response . errors . length ) . toEqual ( 1 ) ;
236+ expect ( response . errors [ 0 ] . code ) . toEqual ( resp . errors [ 0 ] . code ) ;
237+ expect ( response . errors [ 0 ] . title ) . toEqual ( resp . errors [ 0 ] . title ) ;
238+ expect ( response . errors [ 0 ] . detail ) . toEqual ( resp . errors [ 0 ] . detail ) ;
239+ } , ( ) => fail ( 'onCompleted has been called' ) ) ;
239240 } ) ;
240241
241242 it ( 'should generate correct query string for array params with findAll' , ( ) => {
@@ -268,7 +269,6 @@ describe('JsonApiDatastore', () => {
268269 } )
269270 ) ) ;
270271 } ) ;
271-
272272 datastore . findRecord ( Author , '1' ) . subscribe ( ( author ) => {
273273 expect ( author ) . toBeDefined ( ) ;
274274 expect ( author . id ) . toBe ( AUTHOR_ID ) ;
@@ -314,12 +314,10 @@ describe('JsonApiDatastore', () => {
314314 } )
315315 ) ) ;
316316 } ) ;
317-
318317 const author = datastore . createRecord ( Author , {
319318 name : AUTHOR_NAME ,
320319 date_of_birth : AUTHOR_BIRTH
321320 } ) ;
322-
323321 author . save ( ) . subscribe ( ( val ) => {
324322 expect ( val . id ) . toBeDefined ( ) ;
325323 expect ( val . id ) . toEqual ( '1' ) ;
@@ -331,11 +329,9 @@ describe('JsonApiDatastore', () => {
331329 expect ( c . request . method ) . toEqual ( RequestMethod . Post ) ;
332330 c . mockRespond ( new Response ( new ResponseOptions ( { status : 204 } ) ) ) ;
333331 } ) ;
334-
335332 const author = datastore . createRecord ( Author , {
336333 name : AUTHOR_NAME
337334 } ) ;
338-
339335 author . save ( ) . subscribe ( ( val ) => {
340336 expect ( val ) . toBeDefined ( ) ;
341337 } ) ;
@@ -351,16 +347,13 @@ describe('JsonApiDatastore', () => {
351347 expect ( obj . relationships . books . data . length ) . toBe ( 1 ) ;
352348 expect ( obj . relationships . books . data [ 0 ] . id ) . toBe ( '10' ) ;
353349 } ) ;
354-
355350 const author = datastore . createRecord ( Author , {
356351 name : AUTHOR_NAME
357352 } ) ;
358-
359353 author . books = [ new Book ( datastore , {
360354 id : '10' ,
361355 title : BOOK_TITLE
362356 } ) ] ;
363-
364357 author . save ( ) . subscribe ( ) ;
365358 } ) ;
366359
@@ -374,15 +367,12 @@ describe('JsonApiDatastore', () => {
374367 expect ( obj . relationships . books . data . length ) . toBe ( 1 ) ;
375368 expect ( obj . relationships . books . data [ 0 ] . attributes . title ) . toBe ( BOOK_TITLE ) ;
376369 } ) ;
377-
378370 const author = datastore . createRecord ( Author , {
379371 name : AUTHOR_NAME
380372 } ) ;
381-
382373 author . books = [ datastore . createRecord ( Book , {
383374 title : BOOK_TITLE
384375 } ) ] ;
385-
386376 author . save ( ) . subscribe ( ) ;
387377 } ) ;
388378
@@ -395,15 +385,12 @@ describe('JsonApiDatastore', () => {
395385 expect ( obj . relationships ) . toBeDefined ( ) ;
396386 expect ( obj . relationships . author . data . id ) . toBe ( AUTHOR_ID ) ;
397387 } ) ;
398-
399388 const book = datastore . createRecord ( Book , {
400389 title : BOOK_TITLE
401390 } ) ;
402-
403391 book . author = new Author ( datastore , {
404392 id : AUTHOR_ID
405393 } ) ;
406-
407394 book . save ( ) . subscribe ( ) ;
408395 } ) ;
409396 } ) ;
@@ -420,16 +407,15 @@ describe('JsonApiDatastore', () => {
420407 expect ( obj . id ) . toBe ( AUTHOR_ID ) ;
421408 expect ( obj . type ) . toBe ( 'authors' ) ;
422409 expect ( obj . relationships ) . toBeUndefined ( ) ;
423- } ) ;
424410
411+ } ) ;
425412 const author = new Author ( datastore , {
426413 id : AUTHOR_ID ,
427414 attributes : {
428415 date_of_birth : parse ( AUTHOR_BIRTH ) ,
429416 name : AUTHOR_NAME
430417 }
431418 } ) ;
432-
433419 author . name = 'Rowling' ;
434420 author . date_of_birth = parse ( '1965-07-31' ) ;
435421 author . save ( ) . subscribe ( ) ;
0 commit comments