tests updated
This commit is contained in:
parent
054cf21c1f
commit
280803f2ad
|
@ -65,7 +65,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
filter = mergeFilters(filter, {where});
|
filter = mergeFilters(ctx.args.filter, {where});
|
||||||
|
|
||||||
let stmt = new ParameterizedSQL(
|
let stmt = new ParameterizedSQL(
|
||||||
`SELECT i.id, i.image, i.name, i.description,
|
`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`
|
LEFT JOIN taxClass tc ON tc.id = i.taxClassFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tags) {
|
if (ctx.args.tags) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (let tag of tags) {
|
for (let tag of ctx.args.tags) {
|
||||||
if (tag.value == null) continue;
|
if (tag.value == null) continue;
|
||||||
let tAlias = `it${i++}`;
|
let tAlias = `it${i++}`;
|
||||||
stmt.merge({
|
stmt.merge({
|
||||||
|
|
|
@ -4,11 +4,10 @@ describe('item filter()', () => {
|
||||||
it('should return 1 result using filter and tags', async() => {
|
it('should return 1 result using filter and tags', async() => {
|
||||||
let filter = {
|
let filter = {
|
||||||
order: 'isActive ASC, name',
|
order: 'isActive ASC, name',
|
||||||
limit: 8,
|
limit: 8
|
||||||
where: {and: [{typeFk: 2}]}
|
|
||||||
};
|
};
|
||||||
let tags = [{value: 'Gem2', tagFk: 58}];
|
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.length).toEqual(1);
|
||||||
expect(result[0].id).toEqual(2);
|
expect(result[0].id).toEqual(2);
|
||||||
|
|
Loading…
Reference in New Issue