catalogFilter back test

This commit is contained in:
Joan Sanchez 2018-09-14 09:37:54 +02:00
parent fa31010069
commit 8feba9f5eb
2 changed files with 30 additions and 7 deletions

View File

@ -27,8 +27,9 @@ class Controller {
name: $translate.instant('Descendant price') name: $translate.instant('Descendant price')
} }
]; ];
this.orderBy = this.orderList[0].order;
this.filter = { this.filter = {
order: this.orderList[0].order order: this.orderBy
}; };
} }

View File

@ -3,15 +3,37 @@ const app = require(`${servicesDir}/order/server/server`);
describe('order catalogFilter()', () => { describe('order catalogFilter()', () => {
it('should return an array of items', async() => { it('should return an array of items', async() => {
let filter = { let filter = {
orderFk: 1, order: 'relevancy DESC, name'
where: {
typeFk: 1
}
}; };
let result = await app.models.Order.catalogFilter(filter); let args = {
orderFk: 4,
categoryFk: 1,
typeFk: 2
};
let tags = [];
let result = await app.models.Order.catalogFilter(filter, args, tags);
let firstItemId = result[0].id; let firstItemId = result[0].id;
expect(result.length).toEqual(2); expect(result.length).toEqual(2);
expect(firstItemId).toEqual(3); expect(firstItemId).toEqual(1);
});
it('should return an array of items based on tag filter', async() => {
let filter = {
order: 'relevancy DESC, name'
};
let args = {
orderFk: 4,
categoryFk: 1,
typeFk: 2
};
let tags = [{tagFk: 56, value: 'Object2'}];
let result = await app.models.Order.catalogFilter(filter, args, tags);
let firstItemId = result[0].id;
expect(result.length).toEqual(1);
expect(firstItemId).toEqual(2);
}); });
}); });