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',
|
type: 'object',
|
||||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
arg: 'search',
|
|
||||||
type: 'string',
|
|
||||||
description: 'Value to filter',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -27,7 +22,7 @@ module.exports = Self => {
|
||||||
verb: 'GET',
|
verb: 'GET',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Self.filter = async(filter = {}, search, options) => {
|
Self.filter = async(filter = {}, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Postcode filter()', () => {
|
fdescribe('Postcode filter()', () => {
|
||||||
it('should retrieve with no filter', async() => {
|
it('should retrieve with no filter', async() => {
|
||||||
const tx = await models.Postcode.beginTransaction({});
|
const tx = await models.Postcode.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
|
||||||
},
|
|
||||||
limit: 1
|
limit: 1
|
||||||
};
|
}, options);
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -26,14 +23,11 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
where: {
|
||||||
where: {
|
search: 46,
|
||||||
search: 46,
|
}
|
||||||
}
|
}, options);
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(4);
|
expect(results.length).toEqual(4);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -48,14 +42,9 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({where: {
|
||||||
filter: {
|
search: 'Alz',
|
||||||
where: {
|
}}, options);
|
||||||
search: 'Alz',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -70,14 +59,9 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({where: {
|
||||||
filter: {
|
search: 'one',
|
||||||
where: {
|
}}, options);
|
||||||
search: 'one',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(4);
|
expect(results.length).toEqual(4);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
where: {
|
||||||
where: {
|
search: 'Ec',
|
||||||
search: 'Ec',
|
}
|
||||||
}
|
}, options);
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
Loading…
Reference in New Issue