#1348 invoiceOut.summary

This commit is contained in:
Carlos Jimenez Ruiz 2019-04-17 11:44:00 +02:00
parent 7595905c5e
commit 2876f19101
1 changed files with 7 additions and 21 deletions

View File

@ -1,40 +1,26 @@
import './index.js';
describe('Route', () => {
describe('InvoiceOut', () => {
describe('Component summary', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('route'));
beforeEach(ngModule('invoiceOut'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnRouteSummary');
controller.route = {id: 1};
controller = $componentController('vnInvoiceOutSummary');
controller.invoiceOut = {id: 1};
}));
describe('getSummary()', () => {
it('should perform a query to set summary', () => {
$httpBackend.when('GET', `/api/Routes/1/summary`).respond(200, 24);
$httpBackend.expect('GET', `/api/Routes/1/summary`);
$httpBackend.when('GET', `/api/InvoiceOuts/1/summary`).respond(200, 'the data you are looking for');
$httpBackend.expect('GET', `/api/InvoiceOuts/1/summary`);
controller.getSummary();
$httpBackend.flush();
expect(controller.summary).toEqual(24);
});
});
describe('sumPackages()', () => {
it('should calculate the packages total', () => {
controller.summary = {
tickets: [
{packages: 3},
{packages: 1}
]
};
controller.sumPackages();
expect(controller.packagesTotal).toEqual(4);
expect(controller.summary).toEqual('the data you are looking for');
});
});
});