72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('travel getEntry()', () => {
|
|
const entryId = 1;
|
|
it('should check the entry contains the id', async() => {
|
|
const tx = await models.Entry.beginTransaction({});
|
|
const options = {transaction: tx};
|
|
|
|
try {
|
|
const entry = await models.Entry.getEntry(entryId, options);
|
|
|
|
expect(entry.id).toEqual(entryId);
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should check the entry contains the supplier name', async() => {
|
|
const tx = await models.Entry.beginTransaction({});
|
|
const options = {transaction: tx};
|
|
|
|
try {
|
|
const entry = await models.Entry.getEntry(entryId, options);
|
|
const supplierName = entry.supplier().nickname;
|
|
|
|
expect(supplierName).toEqual('Plants nick');
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should check the entry contains the receiver warehouse name', async() => {
|
|
const tx = await models.Entry.beginTransaction({});
|
|
const options = {transaction: tx};
|
|
|
|
try {
|
|
const entry = await models.Entry.getEntry(entryId, options);
|
|
const receiverWarehouseName = entry.travel().warehouseIn().name;
|
|
|
|
expect(receiverWarehouseName).toEqual('Warehouse One');
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should check the entry contains the company code', async() => {
|
|
const tx = await models.Entry.beginTransaction({});
|
|
const options = {transaction: tx};
|
|
|
|
try {
|
|
const entry = await models.Entry.getEntry(entryId, options);
|
|
const companyCode = entry.company().code;
|
|
|
|
expect(companyCode).toEqual('VNL');
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|