47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import './index';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('Component vnClientWebPayment', () => {
|
|
let $httpBackend;
|
|
let $scope;
|
|
let vnApp;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => {
|
|
$scope = $rootScope.$new();
|
|
$scope.model = crudModel;
|
|
$httpBackend = _$httpBackend_;
|
|
vnApp = _vnApp_;
|
|
jest.spyOn(vnApp, 'showError');
|
|
const $element = angular.element('<vn-client-web-payment></vn-client-web-payment>');
|
|
controller = $componentController('vnClientWebPayment', {$element, $scope});
|
|
}));
|
|
|
|
describe('confirm()', () => {
|
|
it(`should confirm a transaction`, () => {
|
|
let transaction = {id: 1};
|
|
let query = 'Clients/confirmTransaction';
|
|
|
|
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');
|
|
});
|
|
});
|
|
});
|