-
Notifications
You must be signed in to change notification settings - Fork 0
/
elements.spec.ts
36 lines (36 loc) · 1.19 KB
/
elements.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
context('Elements example', () => {
it('should load BasisTheoryElements dynamically', () => {
cy.intercept(/https:\/\/.+?\/elements/u, {
body: `
window.BasisTheoryElements = {
init: (apiKey, baseUrl) => {
alert("BasisTheoryElements " + apiKey + " " + baseUrl);
},
};
if (window.BasisTheory) {
window.BasisTheory.elements = window.BasisTheoryElements;
}`,
});
cy.visit('cypress/fixtures/elements.html');
cy.on('window:alert', (val) => {
expect(val).to.equal(
`BasisTheoryElements 04ab9d12-4959-4c48-ba03-9ef722efcc5a https://elements.basistheory.com`
);
});
});
it('should handle blocked BasisTheoryElements script request', () => {
cy.intercept(`http://cypress.test/events/initError`, (req) => {
req.reply({});
}).as(`initErrorEvent`);
cy.intercept(/https:\/\/.+?\/elements/u, {
statusCode: 400,
});
cy.visit('cypress/fixtures/elements.html');
cy.wait('@initErrorEvent')
.its('request.body')
.should(
'equal',
'There was an unknown error when loading Basis Theory Elements. Check the console for details.'
);
});
});