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