test: fix postcode filter back test
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
dbe0f4497c
commit
2ac8760061
|
@ -12,11 +12,6 @@ module.exports = Self => {
|
|||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'string',
|
||||
description: 'Value to filter',
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
|
@ -27,7 +22,7 @@ module.exports = Self => {
|
|||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
Self.filter = async(filter = {}, search, options) => {
|
||||
Self.filter = async(filter = {}, options) => {
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('Postcode filter()', () => {
|
||||
fdescribe('Postcode filter()', () => {
|
||||
it('should retrieve with no filter', async() => {
|
||||
const tx = await models.Postcode.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
},
|
||||
const results = await models.Postcode.filter({
|
||||
limit: 1
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
@ -26,14 +23,11 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
const results = await models.Postcode.filter({
|
||||
where: {
|
||||
search: 46,
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(4);
|
||||
await tx.rollback();
|
||||
|
@ -48,14 +42,9 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
const results = await models.Postcode.filter({where: {
|
||||
search: 'Alz',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
@ -70,14 +59,9 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
const results = await models.Postcode.filter({where: {
|
||||
search: 'one',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}}, options);
|
||||
|
||||
expect(results.length).toEqual(4);
|
||||
await tx.rollback();
|
||||
|
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
const results = await models.Postcode.filter({
|
||||
where: {
|
||||
search: 'Ec',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
|
Loading…
Reference in New Issue