40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('invoiceOut book()', () => {
|
|
const invoiceOutId = 5;
|
|
let bookedDate;
|
|
let OriginalInvoiceOut;
|
|
let updatedInvoiceOut;
|
|
|
|
afterAll(async done => {
|
|
updatedInvoiceOut.updateAttributes({
|
|
booked: OriginalInvoiceOut.booked,
|
|
hasPdf: OriginalInvoiceOut.hasPdf,
|
|
amount: OriginalInvoiceOut.amount
|
|
});
|
|
|
|
done();
|
|
});
|
|
|
|
it('should check that invoice out booked is untainted', async() => {
|
|
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
|
|
|
bookedDate = invoiceOut.booked;
|
|
|
|
expect(invoiceOut.booked).toBeDefined();
|
|
expect(invoiceOut.hasPdf).toBeTruthy();
|
|
});
|
|
|
|
it(`should confirm the book property have been updated`, async() => {
|
|
OriginalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
|
let invoiceOutRef = OriginalInvoiceOut.ref;
|
|
|
|
await app.models.InvoiceOut.book(invoiceOutRef);
|
|
|
|
updatedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
|
|
|
expect(updatedInvoiceOut.booked).not.toEqual(bookedDate);
|
|
expect(updatedInvoiceOut.hasPdf).toBeFalsy();
|
|
});
|
|
});
|