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_; spyOn(vnApp, 'showError'); controller = $componentController('vnClientWebPayment', {$scope: $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'); }); }); });