Skip to content

Commit 7f308a1

Browse files
Merge pull request #572 from cloudinary/test/search-by-asset-id
unit tests for searching by asset-id
2 parents e43e4de + 4cce89f commit 7f308a1

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/integration/api/search/search_spec.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const {
2121
} = TAGS;
2222

2323
const SEARCH_TAG = 'npm_advanced_search_' + UNIQUE_JOB_SUFFIX_ID;
24-
24+
const ASSET_IDS = [];
2525

2626
describe("search_api", function () {
2727
describe("unit", function () {
@@ -110,6 +110,11 @@ describe("search_api", function () {
110110
context: "stage=validated"
111111
})
112112
]).delay(10000)
113+
.then((uploadResults) => {
114+
uploadResults.forEach(({ value }) => {
115+
ASSET_IDS.push(value.asset_id);
116+
});
117+
});
113118
});
114119

115120
after(function () {
@@ -133,6 +138,25 @@ describe("search_api", function () {
133138
expect(results.resources.length).to.eql(1);
134139
});
135140
});
141+
142+
it(`should allow search by exact asset_id`, function () {
143+
const [exampleAssetId] = ASSET_IDS;
144+
return cloudinary.v2.search.expression(`asset_id=${exampleAssetId}`)
145+
.execute()
146+
.then(function (results) {
147+
expect(results.resources.length).to.eql(1);
148+
});
149+
});
150+
151+
it(`should allow search by tokenized asset_id`, function () {
152+
const [exampleAssetId] = ASSET_IDS;
153+
return cloudinary.v2.search.expression(`asset_id:${exampleAssetId}`)
154+
.execute()
155+
.then(function (results) {
156+
expect(results.resources.length).to.eql(1);
157+
});
158+
});
159+
136160
it('should paginate resources limited by tag and orderd by ascing public_id', function () {
137161
return cloudinary.v2.search.max_results(1).expression(`tags:${SEARCH_TAG}`)
138162
.sort_by('public_id', 'asc')

0 commit comments

Comments
 (0)