back end unit tests for zone endpoints
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b651fdebe6
commit
0421fd8828
|
@ -0,0 +1,20 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('zone getEvents()', () => {
|
||||
it('should return all events for the specified geo and agency mode', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
let result = await app.models.Zone.getEvents(20, 1, options);
|
||||
|
||||
expect(result.events.length).toEqual(10);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('zone getLeaves()', () => {
|
||||
it('should return the country and the childs containing the search value', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
let result = await app.models.Zone.getLeaves(1, null, '46000', options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,56 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('zone toggleIsIncluded()', () => {
|
||||
it('should return the created location with isIncluded true', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
let result = await app.models.Zone.toggleIsIncluded(1, 20, true, options);
|
||||
|
||||
expect(result.isIncluded).toBeTrue();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the created location with isIncluded false', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
let result = await app.models.Zone.toggleIsIncluded(1, 20, false, options);
|
||||
|
||||
expect(result.isIncluded).toBeFalse();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the amount of deleted locations', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await app.models.Zone.toggleIsIncluded(1, 20, false, options);
|
||||
|
||||
let result = await app.models.Zone.toggleIsIncluded(1, 20, undefined, options);
|
||||
|
||||
expect(result).toEqual({count: 1});
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue