salix/modules/ticket/front/sms/index.spec.js

50 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-01-15 12:27:14 +00:00
import './index';
2020-01-16 11:40:28 +00:00
describe('Ticket', () => {
describe('Component vnTicketSms', () => {
2020-01-15 12:27:14 +00:00
let controller;
let $httpBackend;
let $element;
2020-01-16 11:40:28 +00:00
beforeEach(ngModule('ticket'));
2020-01-15 12:27:14 +00:00
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
let $scope = $rootScope.$new();
$element = angular.element('<vn-dialog></vn-dialog>');
2020-01-16 11:40:28 +00:00
controller = $componentController('vnTicketSms', {$element, $scope});
controller.$params = {id: 11};
2020-01-15 12:27:14 +00:00
}));
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');
2020-01-16 11:40:28 +00:00
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);
2020-01-15 12:27:14 +00:00
controller.onResponse('accept');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
});
});
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);
});
});
});
});