Skip to content

Commit

Permalink
Fixed promoting items (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoreram authored Jul 15, 2018
1 parent e0fb697 commit 518ea45
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apisearch",
"version": "0.2.6",
"version": "0.2.7",
"description": "Javascript client for Apisearch.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ export class Query {
for (const i in this.itemsPromoted) {
array
.items_promoted
.push(this.itemsPromoted[i].toArray);
.push(this.itemsPromoted[i].toArray());
}
}

Expand Down
17 changes: 17 additions & 0 deletions test/Query/Query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,23 @@ describe('Query()', () => {
type: 'marvel'
});
});

it('should work properly when doing toArray', () => {
// Promote thi two uuids into an existing array from the last test
query.promoteUUIDs(
new ItemUUID('ironman', 'marvel'),
new ItemUUID('thor', 'marvel')
);
expect(query.toArray().items_promoted.length).to.equal(2);
expect(query.toArray().items_promoted[0]).to.deep.equal({
id: 'ironman',
type: 'marvel'
});
expect(query.toArray().items_promoted[1]).to.deep.equal({
id: 'thor',
type: 'marvel'
});
});
});

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

0 comments on commit 518ea45

Please sign in to comment.