40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
const moment = require('moment');
|
|
|
|
describe('getInvoiceDate()', () => {
|
|
const companyFk = 442;
|
|
let tx;
|
|
let options;
|
|
|
|
beforeEach(async() => {
|
|
tx = await models.InvoiceOut.beginTransaction({});
|
|
options = {transaction: tx};
|
|
});
|
|
|
|
afterEach(async() => {
|
|
await tx.rollback();
|
|
});
|
|
|
|
it('should return a correct date for serialType "global"', async() => {
|
|
const serialType = 'global';
|
|
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
|
|
|
expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2000-12-01');
|
|
});
|
|
|
|
it('should return null for serialType "multiple"', async() => {
|
|
const serialType = 'multiple';
|
|
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
|
|
|
expect(result.issued).toBeNull();
|
|
});
|
|
|
|
it('should return correct date for serialType "quick"', async() => {
|
|
const serialType = 'quick';
|
|
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
|
|
|
expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2001-01-01');
|
|
});
|
|
});
|
|
|