2018-08-09 12:42:02 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientAddressIndex', () => {
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2018-08-09 12:42:02 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => {
|
2018-08-09 12:42:02 +00:00
|
|
|
$state = _$state_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.model = {
|
|
|
|
refresh: () => {}
|
|
|
|
};
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnClientAddressIndex', {$state, $scope});
|
2018-08-09 12:42:02 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('setDefault()', () => {
|
|
|
|
it('should perform a PATCH if the address is active and call the refresh method', () => {
|
|
|
|
spyOn($scope.model, 'refresh');
|
|
|
|
|
|
|
|
let address = {id: 1, isActive: true};
|
|
|
|
|
|
|
|
$httpBackend.when('PATCH', `/client/api/Addresses/1`).respond(200);
|
|
|
|
$httpBackend.expect('PATCH', `/client/api/Addresses/1`);
|
|
|
|
controller.setDefault(address);
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect($scope.model.refresh).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|