tests updated
gitea/salix/PR-11 This commit looks good Details
gitea/salix/PR-12 This commit looks good Details

This commit is contained in:
Gerard 2019-02-19 11:17:08 +01:00
parent 054cf21c1f
commit 280803f2ad
2 changed files with 5 additions and 6 deletions

View File

@ -65,7 +65,7 @@ module.exports = Self => {
}
});
filter = mergeFilters(filter, {where});
filter = mergeFilters(ctx.args.filter, {where});
let stmt = new ParameterizedSQL(
`SELECT i.id, i.image, i.name, i.description,
@ -86,9 +86,9 @@ module.exports = Self => {
LEFT JOIN taxClass tc ON tc.id = i.taxClassFk`
);
if (tags) {
if (ctx.args.tags) {
let i = 1;
for (let tag of tags) {
for (let tag of ctx.args.tags) {
if (tag.value == null) continue;
let tAlias = `it${i++}`;
stmt.merge({

View File

@ -4,11 +4,10 @@ describe('item filter()', () => {
it('should return 1 result using filter and tags', async() => {
let filter = {
order: 'isActive ASC, name',
limit: 8,
where: {and: [{typeFk: 2}]}
limit: 8
};
let tags = [{value: 'Gem2', tagFk: 58}];
let result = await app.models.Item.filter(filter, tags);
let result = await app.models.Item.filter({args: {filter: filter, typeFk: 2, tags: tags}});
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(2);