2018-09-28 13:00:12 +00:00
|
|
|
import './index';
|
2018-12-27 11:54:16 +00:00
|
|
|
import crudModel from 'core/mocks/crud-model';
|
2018-09-28 13:00:12 +00:00
|
|
|
|
|
|
|
describe('Component vnClientWebPayment', () => {
|
|
|
|
let $httpBackend;
|
|
|
|
let $scope;
|
|
|
|
let vnApp;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2018-09-28 13:00:12 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => {
|
2018-09-28 13:00:12 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.model = crudModel;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
vnApp = _vnApp_;
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(vnApp, 'showError');
|
2018-09-28 13:00:12 +00:00
|
|
|
controller = $componentController('vnClientWebPayment', {$scope: $scope});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('confirm()', () => {
|
|
|
|
it(`should confirm a transaction`, () => {
|
|
|
|
let transaction = {id: 1};
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = 'Clients/confirmTransaction';
|
2018-09-28 13:00:12 +00:00
|
|
|
|
|
|
|
controller.confirm(transaction);
|
|
|
|
$httpBackend.when('POST', query, transaction).respond('ok');
|
|
|
|
$httpBackend.expect('POST', query, transaction);
|
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getFormattedMessage()', () => {
|
|
|
|
it(`should return error message and response Message`, () => {
|
|
|
|
let transaction = {
|
|
|
|
errorMessage: 'My error message',
|
|
|
|
responseMessage: 'My response message'
|
|
|
|
};
|
|
|
|
let result = controller.getFormattedMessage(transaction);
|
|
|
|
|
|
|
|
expect(result).toContain('My error message');
|
|
|
|
expect(result).toContain('My response message');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|