37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
import './index';
|
|
|
|
describe('Client', () => {
|
|
describe('Component vnClientSms', () => {
|
|
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('vnClientSms', {$element});
|
|
controller.client = {id: 101};
|
|
}));
|
|
|
|
describe('onResponse()', () => {
|
|
it('should perform a POST query and show a success snackbar', () => {
|
|
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
|
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
|
|
|
spyOn(controller.vnApp, 'showMessage');
|
|
$httpBackend.when('POST', `/client/api/Sms/send`, params).respond(200, params);
|
|
$httpBackend.expect('POST', `/client/api/Sms/send`, params).respond(params);
|
|
|
|
controller.onResponse('ACCEPT');
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
|
});
|
|
});
|
|
});
|
|
});
|