38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('isEditable()', () => {
|
|
it('should return false if It is able to edit', async() => {
|
|
const tx = await models.Ticket.beginTransaction({});
|
|
let result;
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
const ctx = {req: {accessToken: {userId: 35}}};
|
|
result = await models.Ticket.isEditable(ctx, 19, options);
|
|
await tx.rollback();
|
|
} catch (error) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
|
|
expect(result).toBeFalse();
|
|
});
|
|
|
|
it('should return true if It is able to edit', async() => {
|
|
const tx = await models.Ticket.beginTransaction({});
|
|
let result;
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
const ctx = {req: {accessToken: {userId: 35}}};
|
|
result = await models.Ticket.isEditable(ctx, 15, options);
|
|
await tx.rollback();
|
|
} catch (error) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
|
|
expect(result).toBeTrue();
|
|
});
|
|
});
|