@@ -16,12 +16,14 @@ const {
1616 PUBLIC_ID_3
1717} = PUBLIC_IDS ;
1818
19+
20+
1921const {
2022 UPLOAD_TAGS
2123} = TAGS ;
2224
2325const SEARCH_TAG = 'npm_advanced_search_' + UNIQUE_JOB_SUFFIX_ID ;
24-
26+ const ASSET_IDS = [ ] ;
2527
2628describe ( "search_api" , function ( ) {
2729 describe ( "unit" , function ( ) {
@@ -110,6 +112,11 @@ describe("search_api", function () {
110112 context : "stage=validated"
111113 } )
112114 ] ) . delay ( 10000 )
115+ . then ( ( uploadResults ) => {
116+ uploadResults . forEach ( ( { value } ) => {
117+ ASSET_IDS . push ( value . asset_id ) ;
118+ } ) ;
119+ } ) ;
113120 } ) ;
114121
115122 after ( function ( ) {
@@ -133,6 +140,25 @@ describe("search_api", function () {
133140 expect ( results . resources . length ) . to . eql ( 1 ) ;
134141 } ) ;
135142 } ) ;
143+
144+ it ( `should allow search by exact asset_id` , function ( ) {
145+ const [ exampleAssetId ] = ASSET_IDS ;
146+ return cloudinary . v2 . search . expression ( `asset_id=${ exampleAssetId } ` )
147+ . execute ( )
148+ . then ( function ( results ) {
149+ expect ( results . resources . length ) . to . eql ( 1 ) ;
150+ } ) ;
151+ } ) ;
152+
153+ it ( `should allow search by tokenized asset_id` , function ( ) {
154+ const [ exampleAssetId ] = ASSET_IDS ;
155+ return cloudinary . v2 . search . expression ( `asset_id:${ exampleAssetId } ` )
156+ . execute ( )
157+ . then ( function ( results ) {
158+ expect ( results . resources . length ) . to . eql ( 1 ) ;
159+ } ) ;
160+ } ) ;
161+
136162 it ( 'should paginate resources limited by tag and orderd by ascing public_id' , function ( ) {
137163 return cloudinary . v2 . search . max_results ( 1 ) . expression ( `tags:${ SEARCH_TAG } ` )
138164 . sort_by ( 'public_id' , 'asc' )
0 commit comments