7679-postCode_town_addRequireds #2804

Merged
alexm merged 6 commits from 7679-postCode_town_addRequireds into master 2024-07-31 05:43:52 +00:00
2 changed files with 20 additions and 44 deletions
Showing only changes of commit 2ac8760061 - Show all commits

View File

@ -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);

View File

@ -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: {
where: {
search: 46,
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({
where: {
search: 46,
}
}, 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: {
search: 'Alz',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({where: {
search: 'Alz',
}}, 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: {
search: 'one',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({where: {
search: 'one',
}}, options);
expect(results.length).toEqual(4);
await tx.rollback();
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
where: {
search: 'Ec',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({
where: {
search: 'Ec',
}
}, options);
expect(results.length).toEqual(1);
await tx.rollback();