import './index.js'; describe('InvoiceIn', () => { 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(''); 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'); }); }); describe('amountsNotMatch getter()', () => { it('should get false when taxamount match with due day amount', () => { controller.summary = { totals: { totalDueDay: 'amount match', totalTaxableBase: 'amount match', totalVat: 'no care' } }; expect(controller.amountsNotMatch).toBeFalsy(); }); it('should get true when taxamount does not match with due day amount', () => { controller.summary = { totals: { totalDueDay: 'amount does not match', totalTaxableBase: 'neither match', totalVat: 'no care' } }; expect(controller.amountsNotMatch).toBeTruthy(); }); }); }); });