2019-03-22 10:10:23 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Route', () => {
|
|
|
|
describe('Component summary', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('route'));
|
2019-03-22 10:10:23 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
controller = $componentController('vnRouteSummary');
|
|
|
|
controller.route = {id: 1};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('getSummary()', () => {
|
|
|
|
it('should perform a query to set summary', () => {
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('GET', `Routes/1/summary`).respond(200, 24);
|
|
|
|
$httpBackend.expect('GET', `Routes/1/summary`);
|
2019-03-22 10:10:23 +00:00
|
|
|
controller.getSummary();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.summary).toEqual(24);
|
|
|
|
});
|
|
|
|
});
|
2019-03-25 12:16:34 +00:00
|
|
|
|
|
|
|
describe('sumPackages()', () => {
|
|
|
|
it('should calculate the packages total', () => {
|
|
|
|
controller.summary = {
|
|
|
|
tickets: [
|
|
|
|
{packages: 3},
|
|
|
|
{packages: 1}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
controller.sumPackages();
|
|
|
|
|
|
|
|
expect(controller.packagesTotal).toEqual(4);
|
|
|
|
});
|
|
|
|
});
|
2019-03-22 10:10:23 +00:00
|
|
|
});
|
|
|
|
});
|