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

32 lines
995 B
JavaScript

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