50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
|
const models = require('vn-loopback/server/server').models;
|
||
|
|
||
|
describe('sale-tracking new()', () => {
|
||
|
it('should update a saleTracking', async() => {
|
||
|
const tx = await models.SaleTracking.beginTransaction({});
|
||
|
|
||
|
try {
|
||
|
const options = {transaction: tx};
|
||
|
const ctx = {req: {accessToken: {userId: 55}}};
|
||
|
|
||
|
const saleFk = 1;
|
||
|
const isChecked = true;
|
||
|
const quantity = 20;
|
||
|
const stateCode = 'PREPARED';
|
||
|
const result = await models.SaleTracking.new(ctx, saleFk, isChecked, quantity, stateCode, options);
|
||
|
|
||
|
expect(result.isChecked).toBe(true);
|
||
|
expect(result.originalQuantity).toBe(20);
|
||
|
|
||
|
await tx.rollback();
|
||
|
} catch (e) {
|
||
|
await tx.rollback();
|
||
|
throw e;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
it('should create a saleTracking', async() => {
|
||
|
const tx = await models.SaleTracking.beginTransaction({});
|
||
|
|
||
|
try {
|
||
|
const options = {transaction: tx};
|
||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||
|
|
||
|
const saleFk = 1;
|
||
|
const isChecked = true;
|
||
|
const quantity = 20;
|
||
|
const stateCode = 'PREPARED';
|
||
|
const result = await models.SaleTracking.new(ctx, saleFk, isChecked, quantity, stateCode, options);
|
||
|
|
||
|
expect(result.isChecked).toBe(true);
|
||
|
expect(result.originalQuantity).toBe(20);
|
||
|
|
||
|
await tx.rollback();
|
||
|
} catch (e) {
|
||
|
await tx.rollback();
|
||
|
throw e;
|
||
|
}
|
||
|
});
|
||
|
});
|