41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const app = require(`${servicesDir}/item/server/server`);
|
|
|
|
describe('item updateTaxes()', () => {
|
|
afterAll(async() => {
|
|
let taxesInFixtures = [{id: 3, taxClassFk: 1}];
|
|
|
|
await app.models.Item.updateTaxes(taxesInFixtures);
|
|
});
|
|
|
|
it('should throw an error if the taxClassFk is blank', async() => {
|
|
let error;
|
|
let taxes = [{id: 3, taxClassFk: undefined}];
|
|
|
|
await app.models.Item.updateTaxes(taxes)
|
|
.catch(err => {
|
|
expect(err.message).toEqual('Tax class cannot be blank');
|
|
error = err;
|
|
});
|
|
|
|
expect(error).toBeDefined();
|
|
});
|
|
|
|
it('should update the tax of a given country of an item', async() => {
|
|
let taxCountry = await app.models.ItemTaxCountry.findById(3);
|
|
|
|
expect(taxCountry.taxClassFk).toEqual(1);
|
|
|
|
let taxes = [{id: 3, taxClassFk: 2}];
|
|
|
|
let result = await app.models.Item.updateTaxes(taxes);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('should confirm the tax class was updated', async() => {
|
|
let taxCountry = await app.models.ItemTaxCountry.findById(3);
|
|
|
|
expect(taxCountry.taxClassFk).toEqual(2);
|
|
});
|
|
});
|