salix/modules/invoiceIn/front/summary/index.spec.js

58 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-04-15 08:46:23 +00:00
import './index.js';
2021-07-08 06:19:30 +00:00
describe('InvoiceIn', () => {
2021-04-15 08:46:23 +00:00
describe('Component summary', () => {
let controller;
let $httpBackend;
let $scope;
beforeEach(ngModule('invoiceIn'));
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
const $element = angular.element('<vn-invoice-in-summary></vn-invoice-in-summary>');
controller = $componentController('vnInvoiceInSummary', {$element, $scope});
controller.invoiceIn = {id: 1};
}));
describe('getSummary()', () => {
it('should perform a query to set summary', () => {
$httpBackend.when('GET', `InvoiceIns/1/summary`).respond(200, 'the data you are looking for');
controller.getSummary();
$httpBackend.flush();
expect(controller.summary).toEqual('the data you are looking for');
});
});
2021-07-03 07:19:03 +00:00
describe('amountsNotMatch getter()', () => {
it('should get false when taxamount match with due day amount', () => {
controller.summary =
{
totals: {
2021-07-08 06:19:30 +00:00
totalDueDay: 'amount match',
totalTaxableBase: 'amount match',
totalVat: 'no care'
2021-07-03 07:19:03 +00:00
}
};
2021-07-08 06:19:30 +00:00
expect(controller.amountsNotMatch).toBeFalsy();
2021-07-03 07:19:03 +00:00
});
it('should get true when taxamount does not match with due day amount', () => {
controller.summary =
{
totals: {
2021-07-08 06:19:30 +00:00
totalDueDay: 'amount does not match',
totalTaxableBase: 'neither match',
totalVat: 'no care'
2021-07-03 07:19:03 +00:00
}
};
2021-07-08 06:19:30 +00:00
expect(controller.amountsNotMatch).toBeTruthy();
2021-07-03 07:19:03 +00:00
});
});
2021-04-15 08:46:23 +00:00
});
});