2020-10-14 09:33:42 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnGeoProvince', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $scope;
|
|
|
|
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
const $element = angular.element('<vn-dialog></vn-dialog>');
|
|
|
|
controller = $componentController('vnGeoProvince', {$element, $scope});
|
2021-06-23 11:24:23 +00:00
|
|
|
controller.client = {id: 1101};
|
2020-10-14 09:33:42 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onAccept()', () => {
|
|
|
|
it('should perform a POST query and show a success snackbar', () => {
|
2021-09-02 12:17:35 +00:00
|
|
|
const params = {name: 'New Jersey', autonomyFk: 1};
|
|
|
|
controller.province = {name: 'New Jersey', autonomyFk: 1};
|
2020-10-14 09:33:42 +00:00
|
|
|
|
|
|
|
jest.spyOn(controller.vnApp, 'showMessage');
|
|
|
|
$httpBackend.expect('PATCH', `provinces`, params).respond(200, params);
|
|
|
|
|
|
|
|
controller.onAccept();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The province has been created');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|