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

48 lines
1.6 KiB
JavaScript
Raw 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;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('client', $translateProvider => {
$translateProvider.translations('en', {});
}));
2018-09-28 13:00:12 +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_;
spyOn(vnApp, 'showError');
controller = $componentController('vnClientWebPayment', {$scope: $scope});
}));
describe('confirm()', () => {
it(`should confirm a transaction`, () => {
let transaction = {id: 1};
let query = '/client/api/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');
});
});
});