-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace /sessions with /paymentMethods (#1055)
* Get checkout payment methods adjustment (#1046) * Replaced /sessions with /paymentMethods for apple pay express (#1047) * Replaced /sessions with /paymentMethods from end of checkout (#1049) * Remove sessions call from My Account (#1050) * chore: removed /sessions related code from the cartridge (#1051) * chore: removed services for sessions (#1053)
- Loading branch information
Showing
28 changed files
with
236 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
.../int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/adyenAccount.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
const store = require('../../../../../store'); | ||
const {initializeCardComponent, submitAddCard} = require('../../adyenAccount') | ||
$.fn.modal = jest.fn(); | ||
|
||
jest.mock('../../commons'); | ||
jest.mock('../../../../../store'); | ||
let checkout; | ||
// Mocking external dependencies | ||
jest.mock('../../../../../store', () => ({ | ||
checkoutConfiguration: { | ||
amount: { value: 0, currency: 'EUR' }, | ||
paymentMethodsConfiguration: { | ||
card: { | ||
onChange: jest.fn(), | ||
}, | ||
}, | ||
onAdditionalDetails: jest.fn(), | ||
}, | ||
})); | ||
|
||
describe('submitAddCard', () => { | ||
beforeEach(() => { | ||
store.checkoutConfiguration = {}; | ||
|
||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('initialize card component', async () => { | ||
document.body.innerHTML = `<div id="card"></div>`; | ||
await initializeCardComponent(); | ||
expect(document.getElementById('card')).toBeDefined(); | ||
}); | ||
|
||
it('should send form data via ajax on submitAddCard call', () => { | ||
const fakeResponse = {redirectAction : 'test'}; | ||
document.body.innerHTML = `<form id="payment-form" action="/fake-action"> | ||
<input type="text" name="fake" value="fake" /> | ||
</form>`; | ||
$.ajax = jest.fn(({ success }) => { | ||
success(fakeResponse); | ||
return { fail: jest.fn() }; | ||
}); | ||
submitAddCard(); | ||
expect($.ajax).toHaveBeenCalledWith({ | ||
type: 'POST', | ||
url: '/fake-action', | ||
data: 'fake=fake', | ||
async: false, | ||
success: expect.any(Function), | ||
}); | ||
}); | ||
|
||
it('should handle redirection action after successful form submission', () => { | ||
const fakeRedirectAction = { type: 'redirect' }; | ||
document.body.innerHTML = `<form id="payment-form" action="/fake-action"> | ||
<input type="text" name="fake" value="fake" /> | ||
</form>`; | ||
$.ajax = jest.fn(({ success }) => { | ||
success({ redirectAction: fakeRedirectAction }); | ||
return { fail: jest.fn() }; | ||
}); | ||
window.location.href = ''; | ||
submitAddCard(); | ||
expect(window.location.href).toBe('http://localhost/'); | ||
}); | ||
|
||
it('should handle errors returned from the server during form submission', () => { | ||
let formErrorsExist = false | ||
const fakeErrorResponse = { error: 'Something went wrong' }; | ||
$.ajax = jest.fn(({ success }) => { | ||
success(fakeErrorResponse); | ||
return { fail: jest.fn() }; | ||
}); | ||
submitAddCard(); | ||
setTimeout(() => { | ||
expect(formErrorsExist).toBeTruthy(); | ||
done(); | ||
}); // Timeout needed for completition of the test | ||
}); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.