diff --git a/spec/support/fixtures/stripejs-mock.js b/spec/support/fixtures/stripejs-mock.js new file mode 100644 index 0000000000..e53f0e1b11 --- /dev/null +++ b/spec/support/fixtures/stripejs-mock.js @@ -0,0 +1,34 @@ +class Element { + mount(el) { + if (typeof el === "string") { + el = document.querySelector(el); + } + + el.innerHTML = ` + + + + + `; + } +} + +window.Stripe = () => { + const fetchLastFour = () => { + return document.getElementById("stripe-cardnumber").value.substr(-4, 4); + }; + + return { + elements: () => { + return { + create: (type, options) => new Element() + }; + }, + + createToken: card => { + return new Promise(resolve => { + resolve({ token: { id: "tok_123", card: { last4: fetchLastFour() } } }); + }); + } + }; +};