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
|
|
|
|
2020-01-14 08:10:54 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
|
2019-03-29 06:29:09 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-01-14 08:10:54 +00:00
|
|
|
let $scope = $rootScope.$new();
|
2019-03-29 06:29:09 +00:00
|
|
|
$element = angular.element('<vn-dialog></vn-dialog>');
|
2020-01-14 08:10:54 +00:00
|
|
|
controller = $componentController('vnClientSms', {$element, $scope});
|
2019-03-29 06:29:09 +00:00
|
|
|
controller.client = {id: 101};
|
2020-01-16 11:40:28 +00:00
|
|
|
controller.$params = {id: 101};
|
2019-03-29 06:29:09 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
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');
|
2020-01-16 11:40:28 +00:00
|
|
|
$httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params);
|
2019-03-29 06:29:09 +00:00
|
|
|
|
2019-10-30 15:57:14 +00:00
|
|
|
controller.onResponse('accept');
|
2019-03-29 06:29:09 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
|
|
|
});
|
|
|
|
});
|
2020-01-14 08:10:54 +00:00
|
|
|
|
|
|
|
describe('charactersRemaining()', () => {
|
|
|
|
it('should return the characters remaining in a element', () => {
|
|
|
|
controller.$scope.message = {
|
|
|
|
input: {
|
|
|
|
textLength: 50
|
|
|
|
},
|
|
|
|
maxlength: 150
|
|
|
|
};
|
|
|
|
|
|
|
|
let result = controller.charactersRemaining();
|
|
|
|
|
|
|
|
expect(result).toEqual(100);
|
|
|
|
});
|
|
|
|
});
|
2019-03-29 06:29:09 +00:00
|
|
|
});
|
|
|
|
});
|