salix/modules/client/front/web-payment/index.spec.js

46 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

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;
beforeEach(ngModule('client'));
2018-09-28 13:00:12 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(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');
2020-03-17 10:17:50 +00:00
const $element = angular.element('<vn-client-web-payment></vn-client-web-payment>');
controller = $componentController('vnClientWebPayment', {$element, $scope});
2018-09-28 13:00:12 +00:00
}));
describe('confirm()', () => {
it(`should confirm a transaction`, () => {
let transaction = {id: 1};
let query = 'Clients/confirmTransaction';
2018-09-28 13:00:12 +00:00
controller.confirm(transaction);
$httpBackend.expect('POST', query, transaction).respond('ok');
2018-09-28 13:00:12 +00:00
$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');
});
});
});