2019-03-29 06:29:09 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientSms', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $element;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2019-03-29 06:29:09 +00:00
|
|
|
|
|
|
|
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', () => {
|
2019-04-16 06:21:20 +00:00
|
|
|
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
|
|
|
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
2019-03-29 06:29:09 +00:00
|
|
|
|
|
|
|
spyOn(controller.vnApp, 'showMessage');
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `Sms/send`, params).respond(200, params);
|
|
|
|
$httpBackend.expect('POST', `Sms/send`, params).respond(params);
|
2019-03-29 06:29:09 +00:00
|
|
|
|
|
|
|
controller.onResponse('ACCEPT');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|