2020-10-20 07:44:44 +00:00
|
|
|
import './index';
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
describe('Supplier', () => {
|
|
|
|
describe('Component vnSupplierSummary', () => {
|
2020-10-20 07:44:44 +00:00
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $scope;
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
beforeEach(ngModule('supplier'));
|
2020-10-20 07:44:44 +00:00
|
|
|
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2020-10-26 07:38:43 +00:00
|
|
|
const $element = angular.element('<vn-supplier-summary></vn-supplier-summary>');
|
|
|
|
controller = $componentController('vnSupplierSummary', {$element, $scope});
|
2020-10-20 07:44:44 +00:00
|
|
|
}));
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
describe('getSummary()', () => {
|
|
|
|
it('should perform a get asking for the supplier data', () => {
|
|
|
|
controller.supplier = {id: 1};
|
2020-10-20 07:44:44 +00:00
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
const query = `Suppliers/${controller.supplier.id}/getSummary`;
|
2020-10-20 07:44:44 +00:00
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
$httpBackend.expectGET(query).respond({id: 1});
|
|
|
|
controller.getSummary();
|
2020-10-20 07:44:44 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
expect(controller.summary).toEqual({id: 1});
|
2020-10-20 07:44:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|