@@ -162,7 +162,7 @@ describe("data", () => {
162162 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
163163 } ) ;
164164
165- it ( "gets one thing by id" , ( ) => {
165+ it ( "gets one thing by id only " , ( ) => {
166166 return client . data
167167 . getterById ( )
168168 . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
@@ -178,6 +178,34 @@ describe("data", () => {
178178 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
179179 } ) ;
180180
181+ it ( "gets one thing by id and class name" , ( ) => {
182+ return client . data
183+ . getterById ( )
184+ . withClassName ( thingClassName )
185+ . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
186+ . do ( )
187+ . then ( ( res ) => {
188+ expect ( res ) . toEqual (
189+ expect . objectContaining ( {
190+ id : "1565c06c-463f-466c-9092-5930dbac3887" ,
191+ properties : { stringProp : "with-id" } ,
192+ } )
193+ ) ;
194+ } )
195+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
196+ } ) ;
197+
198+ it ( "fails to get one thing by id with invalid class name" , ( ) => {
199+ return client . data
200+ . getterById ( )
201+ . withClassName ( "DoesNotExist" )
202+ . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
203+ . do ( )
204+ . catch ( err =>
205+ expect ( err ) . toEqual ( "usage error (500): {\"error\":[{\"message\":\"repo: object by id: index not found for class DoesNotExist\"}]}" )
206+ ) ;
207+ } ) ;
208+
181209 it ( "gets one thing by id with all optional additional props" , ( ) => {
182210 return client . data
183211 . getterById ( )
@@ -211,7 +239,7 @@ describe("data", () => {
211239 } ) ;
212240 } ) ;
213241
214- it ( "updates a thing" , ( ) => {
242+ it ( "updates a thing by id only " , ( ) => {
215243 const id = "1565c06c-463f-466c-9092-5930dbac3887" ;
216244 return client . data
217245 . getterById ( )
@@ -236,6 +264,31 @@ describe("data", () => {
236264 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
237265 } ) ;
238266
267+ it ( "updates a thing by id and class name" , ( ) => {
268+ const id = "1565c06c-463f-466c-9092-5930dbac3887" ;
269+ return client . data
270+ . getterById ( )
271+ . withId ( id )
272+ . withClassName ( thingClassName )
273+ . do ( )
274+ . then ( ( res ) => {
275+ const properties = res . properties ;
276+ properties . stringProp = "thing-updated-with-class-name" ;
277+ return client . data
278+ . updater ( )
279+ . withId ( id )
280+ . withClassName ( thingClassName )
281+ . withProperties ( properties )
282+ . do ( ) ;
283+ } )
284+ . then ( ( res ) => {
285+ expect ( res . properties ) . toEqual ( {
286+ stringProp : "thing-updated-with-class-name" ,
287+ } ) ;
288+ } )
289+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
290+ } ) ;
291+
239292 it ( "merges a thing" , ( ) => {
240293 const id = "1565c06c-463f-466c-9092-5930dbac3887" ;
241294 return client . data
@@ -301,7 +354,7 @@ describe("data", () => {
301354 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
302355 } ) ;
303356
304- it ( "checks that object exists" , ( ) => {
357+ it ( "checks that object exists by id only " , ( ) => {
305358 return client . data
306359 . checker ( )
307360 . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
@@ -314,15 +367,29 @@ describe("data", () => {
314367 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
315368 } ) ;
316369
317- it ( "deletes a thing" , ( ) => {
370+ it ( "checks that object exists by id and class name" , ( ) => {
371+ return client . data
372+ . checker ( )
373+ . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
374+ . withClassName ( thingClassName )
375+ . do ( )
376+ . then ( ( exists ) => {
377+ if ( ! exists ) {
378+ fail ( "it should exist in DB" )
379+ }
380+ } )
381+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
382+ } ) ;
383+
384+ it ( "deletes a thing by id only" , ( ) => {
318385 return client . data
319386 . deleter ( )
320387 . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
321388 . do ( )
322389 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
323390 } ) ;
324391
325- it ( "checks that object doesn't exist anymore" , ( ) => {
392+ it ( "checks that object doesn't exist anymore with delete by id only " , ( ) => {
326393 return client . data
327394 . checker ( )
328395 . withId ( "1565c06c-463f-466c-9092-5930dbac3887" )
@@ -335,11 +402,41 @@ describe("data", () => {
335402 . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
336403 } ) ;
337404
338- it ( "waits for es index updates" , ( ) => {
339- return new Promise ( ( resolve , reject ) => {
340- // TODO: remove in 1.0.0
341- setTimeout ( resolve , 1000 ) ;
342- } ) ;
405+ it ( "deletes a thing with id and class name" , async ( ) => {
406+ const properties = { stringProp : "with-id" } ;
407+ const id = "6781a974-cfbf-455d-ace8-f1dba4564230" ;
408+
409+ await client . data
410+ . creator ( )
411+ . withClassName ( thingClassName )
412+ . withProperties ( properties )
413+ . withId ( id )
414+ . do ( )
415+ . then ( ( res ) => {
416+ expect ( res . properties ) . toEqual ( properties ) ;
417+ expect ( res . id ) . toEqual ( id ) ;
418+ } )
419+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
420+
421+ return client . data
422+ . deleter ( )
423+ . withId ( id )
424+ . withClassName ( thingClassName )
425+ . do ( )
426+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
427+ } )
428+
429+ it ( "checks that object doesn't exist anymore with delete by id and class name" , ( ) => {
430+ return client . data
431+ . checker ( )
432+ . withId ( "6781a974-cfbf-455d-ace8-f1dba4564230" )
433+ . do ( )
434+ . then ( ( exists ) => {
435+ if ( exists ) {
436+ fail ( "it should not exist in DB" )
437+ }
438+ } )
439+ . catch ( ( e ) => fail ( "it should not have errord: " + e ) ) ;
343440 } ) ;
344441
345442 it ( "verifies there are now fewer things (after delete)" , ( ) => {
0 commit comments