55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('order isEditable()', () => {
|
|
it('should return false when the given order is not editable', async() => {
|
|
const tx = await models.Order.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const isEditable = await models.Order.isEditable(2, options);
|
|
|
|
expect(isEditable).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should return false when the given order doesnt exists', async() => {
|
|
const tx = await models.Order.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const isEditable = await models.Order.isEditable(999, options);
|
|
|
|
expect(isEditable).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should return true when the given order is editable', async() => {
|
|
const tx = await models.Order.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const isEditable = await models.Order.isEditable(16, options);
|
|
|
|
expect(isEditable).toBeTruthy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|