2023-11-09 14:53:41 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2024-06-11 07:39:06 +00:00
|
|
|
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
2023-11-09 14:53:41 +00:00
|
|
|
|
|
|
|
describe('invoiceInDueDay new()', () => {
|
|
|
|
beforeAll(async() => {
|
2024-06-11 07:39:06 +00:00
|
|
|
mockLoopBackContext();
|
2023-11-09 14:53:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly create a new due day', async() => {
|
|
|
|
const userId = 9;
|
2024-04-16 06:44:50 +00:00
|
|
|
const invoiceInFk = 3;
|
2023-11-09 14:53:41 +00:00
|
|
|
|
|
|
|
const ctx = {
|
|
|
|
req: {
|
|
|
|
accessToken: {userId: userId},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const tx = await models.InvoiceIn.beginTransaction({});
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
await models.InvoiceInDueDay.destroyAll({
|
|
|
|
invoiceInFk
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
await models.InvoiceInDueDay.new(ctx, invoiceInFk, options);
|
|
|
|
|
|
|
|
const result = await models.InvoiceInDueDay.find({where: {invoiceInFk}}, options);
|
|
|
|
|
|
|
|
expect(result).toBeDefined();
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|