8355-testToMaster #3336

Merged
alexm merged 241 commits from 8355-testToMaster into master 2025-01-07 06:44:57 +00:00
2 changed files with 67 additions and 1 deletions
Showing only changes of commit 59b5dd5a36 - Show all commits

View File

@ -0,0 +1,66 @@
const models = require('vn-loopback/server/server').models;
fdescribe('invoiceIn', () => {
let options;
let tx;
const invoiceId = 1;
const supplierId = 791;
const currencyId = 1;
const companyId = 442;
beforeEach(async() => {
options = {transaction: tx};
tx = await models.InvoiceIn.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should allow insert for new instance', async() => {
const newInvoice = {
supplierFk: supplierId,
issued: Date.vnNew(),
operated: Date.vnNew(),
currencyFk: currencyId,
companyFk: companyId,
isBooked: false
};
const createdInvoice = await models.InvoiceIn.create(newInvoice, options);
expect(createdInvoice).toBeDefined();
expect(createdInvoice.id).toBeDefined();
});
it('should throw an error if trying to update a booked invoice', async() => {
const invoice = await models.InvoiceIn.findById(invoiceId, null, options);
await invoice.updateAttribute('isBooked', true, options);
let error;
try {
await invoice.updateAttribute('supplierFk', supplierId, options);
} catch (err) {
error = err;
}
expect(error).toBeDefined();
expect(error.message).toBe('InvoiceIn is already booked');
});
it('should throw an error if trying to delete a booked invoice', async() => {
const invoice = await models.InvoiceIn.findById(invoiceId, null, options);
await invoice.updateAttribute('isBooked', true, options);
let error;
try {
await models.InvoiceIn.deleteById(invoiceId, options);
} catch (err) {
error = err;
}
expect(error).toBeDefined();
expect(error.sqlMessage).toBe('InvoiceIn is already booked');
});
});

View File

@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
const invoiceInId = 1; const invoiceInId = 1;
const supplierId = 791; const supplierId = 791;
fdescribe('invoiceIn updateInvoiceIn()', () => { describe('invoiceIn updateInvoiceIn()', () => {
const ctx = beforeAll.getCtx(); const ctx = beforeAll.getCtx();
let options; let options;
let tx; let tx;