2019-07-08 12:07:09 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
2020-10-14 09:33:42 +00:00
|
|
|
describe('Component vnGeoPostcode', () => {
|
2019-07-08 12:07:09 +00:00
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
2020-03-17 10:17:50 +00:00
|
|
|
let $scope;
|
2019-07-08 12:07:09 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2019-07-08 12:07:09 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
2019-07-08 12:07:09 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-03-17 10:17:50 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
const $element = angular.element('<vn-dialog></vn-dialog>');
|
2020-10-14 09:33:42 +00:00
|
|
|
controller = $componentController('vnGeoPostcode', {$element, $scope});
|
2021-06-23 11:24:23 +00:00
|
|
|
controller.client = {id: 1101};
|
2019-07-08 12:07:09 +00:00
|
|
|
}));
|
|
|
|
|
2020-03-03 14:03:54 +00:00
|
|
|
describe('onAccept()', () => {
|
2019-07-08 12:07:09 +00:00
|
|
|
it('should perform a POST query and show a success snackbar', () => {
|
|
|
|
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
2020-10-14 09:33:42 +00:00
|
|
|
controller.location = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
2019-07-08 12:07:09 +00:00
|
|
|
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.vnApp, 'showMessage');
|
2020-07-23 15:10:07 +00:00
|
|
|
$httpBackend.expect('PATCH', `postcodes`, params).respond(200, params);
|
2019-07-08 12:07:09 +00:00
|
|
|
|
2020-03-03 14:03:54 +00:00
|
|
|
controller.onAccept();
|
2019-07-08 12:07:09 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-10-14 09:33:42 +00:00
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been created. You can save the data now');
|
2019-07-08 12:07:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|