refs #6028 test(route): add getRoutesByWorker
This commit is contained in:
parent
639d5963a3
commit
3e3c7ea977
|
@ -37,7 +37,7 @@ ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
|
|||
|
||||
INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
|
||||
VALUES
|
||||
('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66);
|
||||
('DEFAULT_TOKEN', '1209600', CURDATE(), 66);
|
||||
|
||||
INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`)
|
||||
VALUES
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getRoutesByWorker', () => {
|
||||
fit('should return the routes of the worker can view all routes', async() => {
|
||||
const deliveryBossId = 57;
|
||||
const ctx = {req: {accessToken: {userId: deliveryBossId}}};
|
||||
const result = await models.Route.getRoutesByWorker(ctx);
|
||||
|
||||
expect(result.length).toEqual(7);
|
||||
});
|
||||
|
||||
fit('should return the routes of the worker can not view all routes', async() => {
|
||||
const deliveryId = 56;
|
||||
const ctx = {req: {accessToken: {userId: deliveryId}}};
|
||||
const result = await models.Route.getRoutesByWorker(ctx);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getRoutesByWorker', () => {
|
||||
it('should return the routes of the worker can view all routes', async() => {
|
||||
const tx = await models.UserConfig.beginTransaction({});
|
||||
|
||||
const deliveryBossId = 57;
|
||||
const options = {transaction: tx};
|
||||
let result;
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: deliveryBossId}}};
|
||||
await models.UserConfig.create({
|
||||
userFk: 57,
|
||||
warehouseFk: 1
|
||||
}, options);
|
||||
result = await models.Route.getRoutesByWorker(ctx, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(result.length).toEqual(7);
|
||||
});
|
||||
|
||||
it('should return the routes of the worker can not view all routes', async() => {
|
||||
const deliveryId = 56;
|
||||
const ctx = {req: {accessToken: {userId: deliveryId}}};
|
||||
const result = await models.Route.getRoutesByWorker(ctx);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue