diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 41d8142..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/node:9.4.0 - - working_directory: ~/bancard-connectors/vpos/checkout/javascript - - steps: - - checkout: - path: ~/bancard-connectors - - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package.json" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: yarn install - - - save_cache: - paths: - - node_modules - key: v1-dependencies-{{ checksum "package.json" }} - - - run: yarn test diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml new file mode 100644 index 0000000..a584d3f --- /dev/null +++ b/.github/workflows/config.yml @@ -0,0 +1,23 @@ +name: Tests + +on: + push: + branches: + - '**' + +jobs: + build: + name: 'Run tests' + runs-on: ubuntu-latest + container: node:9.4.0 + defaults: + run: + working-directory: ./vpos/checkout/javascript + + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + - run: yarn install --frozen-lockfile + - run: yarn test + diff --git a/vpos/checkout/javascript/src/bancard-checkout.js b/vpos/checkout/javascript/src/bancard-checkout.js index c34b811..03102cb 100644 --- a/vpos/checkout/javascript/src/bancard-checkout.js +++ b/vpos/checkout/javascript/src/bancard-checkout.js @@ -7,6 +7,7 @@ const ZIMPLE_IFRAME_URL = `${constants.BANCARD_URL}/checkout/zimple/new`; const ALLOWED_STYLES_URL = `${constants.BANCARD_URL}/checkout/allowed_styles`; const CONFIRMATION_IFRAME_URL = `${constants.BANCARD_URL}/alias_token/confirmation/new`; const PREAUTHORIZATION_IFRAME_URL = `${constants.BANCARD_URL}/checkout/preauthorization/new`; +const CHARGE3DS_IFRAME_URL = `${constants.BANCARD_URL}/checkout/charge_3ds/new`; const Settings = { handler: 'default', @@ -233,6 +234,17 @@ class Bancard { }; } + get Charge3DS() { + return { + createForm: (divId, processId, options) => { + this.divId = divId; + internalMethods.createForm({ + divId, processId, options, url: CHARGE3DS_IFRAME_URL, + }); + }, + }; + } + destroy() { const iframeContainer = window.document.getElementById(this.divId); diff --git a/vpos/checkout/javascript/src/specs/bancard-checkout.test.js b/vpos/checkout/javascript/src/specs/bancard-checkout.test.js index 6f65efe..4af6d94 100644 --- a/vpos/checkout/javascript/src/specs/bancard-checkout.test.js +++ b/vpos/checkout/javascript/src/specs/bancard-checkout.test.js @@ -171,6 +171,24 @@ describe('Bancard', () => { .toBe('https://desa.infonet.com.py:8085/checkout/preauthorization/new?process_id=1234'); }); }); + + describe('Charge3DS', () => { + beforeEach(() => { + instance.Charge3DS.createForm('targetDiv', '1234'); + window.location.replace = jest.fn(); + }); + + afterEach(() => { instance.destroy(); }); + + test('It creates the iframe', () => { + expect(document.querySelectorAll('iframe').length).toBe(1); + }); + + test('Iframe points to correct URL', () => { + expect(document.querySelectorAll('iframe')[0].getAttribute('src')) + .toBe('https://desa.infonet.com.py:8085/checkout/charge_3ds/new?process_id=1234'); + }); + }); }); describe('When the div does not exist', () => {