@@ -595,6 +595,41 @@ describe('openSenseMap API Routes: /boxes', function () {
595595 return chakram . wait ( ) ;
596596 } ) ;
597597 } ) ;
598+ it ( 'should allow to update the box via PUT with array as grouptags' , function ( ) {
599+ const update_payload = { name : 'neuername' , exposure : 'outdoor' , grouptag : [ 'newgroup' ] , description : 'total neue beschreibung' , location : { lat : 54.2 , lng : 21.1 } , weblink : 'http://www.google.de' , image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=' } ;
600+
601+ return chakram . put ( `${ BASE_URL } /boxes/${ boxIds [ 2 ] } ` , update_payload , { headers : { 'Authorization' : `Bearer ${ jwt2 } ` } } )
602+ . then ( function ( response ) {
603+ expect ( response ) . to . have . status ( 200 ) ;
604+ expect ( response ) . to . comprise . of . json ( 'data.name' , update_payload . name ) ;
605+ expect ( response ) . to . comprise . of . json ( 'data.exposure' , update_payload . exposure ) ;
606+ expect ( response . body . data . grouptag ) . to . have . same . members ( update_payload . grouptag ) ;
607+ expect ( response ) . to . comprise . of . json ( 'data.description' , update_payload . description ) ;
608+ expect ( response ) . to . comprise . of . json ( 'data.currentLocation' , {
609+ type : 'Point' ,
610+ coordinates : [ update_payload . location . lng , update_payload . location . lat ]
611+ } ) ;
612+
613+ // loc field with old schema (backwards compat):
614+ expect ( response ) . to . comprise . of . json ( 'data.loc' , [ {
615+ type : 'Feature' ,
616+ geometry : {
617+ type : 'Point' ,
618+ coordinates : [
619+ update_payload . location . lng ,
620+ update_payload . location . lat
621+ ]
622+ }
623+ } ] ) ;
624+
625+ // image should contain timestamp. request duration should be less than 1s.
626+ expect ( response ) . to . comprise . of . json ( 'data.image' , function ( image ) {
627+ return expect ( moment ( ) . diff ( moment ( parseInt ( image . split ( '_' ) [ 1 ] . slice ( 0 , - 4 ) , 36 ) * 1000 ) ) ) . to . be . below ( 1000 ) ;
628+ } ) ;
629+
630+ return chakram . wait ( ) ;
631+ } ) ;
632+ } ) ;
598633
599634 it ( 'should deny to update a box of other users' , function ( ) {
600635 let otherJwt , otherBoxId ;
@@ -677,7 +712,7 @@ describe('openSenseMap API Routes: /boxes', function () {
677712 expect ( response ) . to . have . status ( 200 ) ;
678713 expect ( response ) . to . have . header ( 'content-type' , 'application/json; charset=utf-8' ) ;
679714 expect ( Array . isArray ( response . body ) ) . to . be . true ;
680- expect ( response . body . length ) . to . be . equal ( 1 ) ;
715+ expect ( response . body . length ) . to . be . equal ( 2 ) ;
681716
682717 return chakram . wait ( ) ;
683718 } ) ;
0 commit comments