salix/modules/client/front/address/index/index.spec.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-08-09 12:42:02 +00:00
import './index';
describe('Client', () => {
describe('Component vnClientAddressIndex', () => {
let controller;
let $scope;
let $state;
let $httpBackend;
beforeEach(ngModule('client'));
2018-08-09 12:42:02 +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: () => {}
};
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();
});
});
});
});