Skip to content

Commit 518ea45

Browse files
authored
Fixed promoting items (#15)
1 parent e0fb697 commit 518ea45

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apisearch",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "Javascript client for Apisearch.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/Query/Query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ export class Query {
11821182
for (const i in this.itemsPromoted) {
11831183
array
11841184
.items_promoted
1185-
.push(this.itemsPromoted[i].toArray);
1185+
.push(this.itemsPromoted[i].toArray());
11861186
}
11871187
}
11881188

test/Query/Query.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ describe('Query()', () => {
330330
type: 'marvel'
331331
});
332332
});
333+
334+
it('should work properly when doing toArray', () => {
335+
// Promote thi two uuids into an existing array from the last test
336+
query.promoteUUIDs(
337+
new ItemUUID('ironman', 'marvel'),
338+
new ItemUUID('thor', 'marvel')
339+
);
340+
expect(query.toArray().items_promoted.length).to.equal(2);
341+
expect(query.toArray().items_promoted[0]).to.deep.equal({
342+
id: 'ironman',
343+
type: 'marvel'
344+
});
345+
expect(query.toArray().items_promoted[1]).to.deep.equal({
346+
id: 'thor',
347+
type: 'marvel'
348+
});
349+
});
333350
});
334351

335352
describe('-> When excluding uuids', () => {

0 commit comments

Comments
 (0)