37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
import './index';
|
|
|
|
describe('Client', () => {
|
|
describe('Component vnClientPostcode', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
let $element;
|
|
|
|
beforeEach(angular.mock.module('client', $translateProvider => {
|
|
$translateProvider.translations('en', {});
|
|
}));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
$element = angular.element('<vn-dialog></vn-dialog>');
|
|
controller = $componentController('vnClientPostcode', {$element});
|
|
controller.client = {id: 101};
|
|
}));
|
|
|
|
describe('onResponse()', () => {
|
|
it('should perform a POST query and show a success snackbar', () => {
|
|
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
|
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
|
|
|
spyOn(controller.vnApp, 'showMessage');
|
|
$httpBackend.when('PATCH', `/api/postcodes`, params).respond(200, params);
|
|
$httpBackend.expect('PATCH', `/api/postcodes`, params).respond(params);
|
|
|
|
controller.onResponse('ACCEPT');
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved');
|
|
});
|
|
});
|
|
});
|
|
});
|