@@ -101,6 +101,23 @@ describe('Inputs', () => {
101101 done ( ) ;
102102 } )
103103 . catch ( errorHandler . bind ( done ) ) ;
104+
105+ app . inputs . create ( {
106+ id : inputId2 ,
107+ url : sampleImages [ 2 ] ,
108+ allowDuplicateUrl : true ,
109+ concepts : [ { id : beerId } ] ,
110+ metadata : { foo : 'bar' , baz2 : 'blah2' }
111+ } )
112+ . then ( inputs => {
113+ expect ( inputs ) . toBeDefined ( ) ;
114+ expect ( inputs instanceof Inputs ) . toBe ( true ) ;
115+ expect ( inputs [ 0 ] . id ) . toBe ( inputId2 ) ;
116+ expect ( inputs [ 0 ] . rawData . data . metadata . foo ) . toBe ( 'bar' ) ;
117+ expect ( inputs [ 0 ] . rawData . status . code === 30000 ) ;
118+ done ( ) ;
119+ } )
120+ . catch ( errorHandler . bind ( done ) ) ;
104121 } ) ;
105122
106123 it ( 'Adds input with geodata' , done => {
@@ -399,15 +416,34 @@ describe('Search', () => {
399416 . catch ( errorHandler . bind ( done ) ) ;
400417 } ) ;
401418
402- it ( 'Filter by images/inputs only' , done => {
403- app . inputs . search ( [
404- { input : { url : sampleImages [ 0 ] } }
405- ] )
419+ it ( 'Filter by image url only' , done => {
420+ app . inputs . search (
421+ {
422+ input :
423+ {
424+ type : 'input' ,
425+ url : sampleImages [ 0 ]
426+ }
427+ } )
406428 . then ( response => {
429+ expect ( response . hits . length ) . not . toBeLessThan ( 1 ) ;
407430 expect ( response . hits [ 0 ] . score ) . toBeDefined ( ) ;
408431 done ( ) ;
409432 } )
410433 . catch ( errorHandler . bind ( done ) ) ;
434+
435+ app . inputs . search (
436+ {
437+ input : {
438+ type : 'input' ,
439+ url : sampleImages [ 3 ]
440+ }
441+ } )
442+ . then ( response => {
443+ expect ( response . hits . length ) . toBe ( 0 ) ;
444+ done ( ) ;
445+ } )
446+ . catch ( errorHandler . bind ( done ) ) ;
411447 } ) ;
412448
413449 it ( 'Filter by concepts/inputs only' , done => {
@@ -434,18 +470,39 @@ describe('Search', () => {
434470 . catch ( errorHandler . bind ( done ) ) ;
435471 } ) ;
436472
437- it ( 'Filter by image id' , done => {
438- app . inputs . search ( { input : { id : inputId1 } } )
473+ it ( 'Filter by image id only' , done => {
474+ app . inputs . search (
475+ {
476+ input :
477+ {
478+ type : 'input' ,
479+ id : inputId1
480+ }
481+ } )
439482 . then ( response => {
483+ expect ( response . hits . length ) . toBe ( 1 ) ;
440484 expect ( response . hits [ 0 ] . score ) . toBeDefined ( ) ;
441485 done ( ) ;
442486 } )
443487 . catch ( errorHandler . bind ( done ) ) ;
444488 } ) ;
445489
446490 it ( 'Filter by image id and url' , done => {
447- app . inputs . search ( { input : { id : inputId1 , url : sampleImages [ 0 ] } } )
491+ app . inputs . search (
492+ [ {
493+ input : {
494+ type : 'input' ,
495+ id : inputId3 ,
496+ }
497+ } ,
498+ {
499+ input : {
500+ type : 'input' ,
501+ url : sampleImages [ 0 ]
502+ }
503+ } ] )
448504 . then ( response => {
505+ expect ( response . hits . length ) . toBe ( 1 ) ;
449506 expect ( response . hits [ 0 ] . score ) . toBeDefined ( ) ;
450507 done ( ) ;
451508 } )
@@ -527,17 +584,22 @@ describe('Search', () => {
527584 } ) ;
528585
529586 it ( 'Filter with metadata and image url' , done => {
530- app . inputs . search ( {
587+ app . inputs . search ( [
588+ {
589+ input : {
590+ type : 'input' ,
591+ url : sampleImages [ 3 ]
592+ }
593+ } ,
594+ {
531595 input : {
532- url : sampleImages [ 3 ] ,
533596 metadata : {
534597 foo : 'bar'
535598 }
536- }
537- } )
599+ } ,
600+ } ] )
538601 . then ( response => {
539- expect ( response . hits . length ) . toBe ( 1 ) ;
540- expect ( response . hits [ 0 ] . score ) . toBeDefined ( ) ;
602+ expect ( response . hits . length ) . toBe ( 0 ) ;
541603 done ( ) ;
542604 } )
543605 . catch ( errorHandler . bind ( done ) ) ;
0 commit comments