salix/modules/order/front/card/index.spec.js

32 lines
995 B
JavaScript
Raw Normal View History

import './index.js';
describe('Order', () => {
describe('Component vnOrderCard', () => {
let controller;
let $httpBackend;
2019-11-10 10:08:44 +00:00
let data = {id: 1, name: 'fooName'};
let total = 10.5;
beforeEach(ngModule('order'));
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
$httpBackend = _$httpBackend_;
2019-11-10 10:08:44 +00:00
let $element = angular.element('<div></div>');
controller = $componentController('vnOrderCard', {$element});
2019-11-10 10:08:44 +00:00
$stateParams.id = data.id;
$httpBackend.whenRoute('GET', 'Orders/:id').respond(data);
$httpBackend.whenRoute('GET', 'Orders/:id/getTotal').respond(200, total);
}));
2019-11-10 10:08:44 +00:00
it('should request data and total, merge them, and set it on the controller', () => {
controller.reload();
$httpBackend.flush();
2019-11-10 10:08:44 +00:00
expect(controller.order).toEqual(Object.assign({}, data, {total}));
});
});
});