diff --git a/test/javascripts/acceptance/payments-test.js.es6 b/test/javascripts/acceptance/payments-test.js.es6 new file mode 100644 index 0000000..cae338b --- /dev/null +++ b/test/javascripts/acceptance/payments-test.js.es6 @@ -0,0 +1,18 @@ +import { acceptance } from "helpers/qunit-helpers"; +import { stubStripe } from "discourse/plugins/discourse-patrons/helpers/stripe"; + +acceptance("Discourse Patrons", { + settings: { + discourse_patrons_amounts: "1.00|2.00" + }, + + beforeEach() { + stubStripe(); + } +}); + +QUnit.test("viewing", async assert => { + await visit("/patrons"); + + assert.ok($(".donations-page-payment").length, "has payment form class"); +}); diff --git a/test/javascripts/components/stripe-card-test.js.es6 b/test/javascripts/components/stripe-card-test.js.es6 index 8e9bf7e..fde27a1 100644 --- a/test/javascripts/components/stripe-card-test.js.es6 +++ b/test/javascripts/components/stripe-card-test.js.es6 @@ -1,4 +1,5 @@ import componentTest from "helpers/component-test"; +import { stubStripe } from "discourse/plugins/discourse-patrons/helpers/stripe"; moduleForComponent("stripe-card", { integration: true }); @@ -6,26 +7,7 @@ componentTest("Discourse Patrons stripe card success", { template: `{{stripe-card handleConfirmStripeCard=onSubmit billing=billing}}`, beforeEach() { - window.Stripe = () => { - return { - createPaymentMethod() { - return new Ember.RSVP.Promise(resolve => { - resolve({}); - }); - }, - elements() { - return { - create() { - return { - on() {}, - card() {}, - mount() {} - }; - } - }; - } - }; - }; + stubStripe(); this.set( "billing", diff --git a/test/javascripts/helpers/discourse-patrons-pretender.js.es6 b/test/javascripts/helpers/discourse-patrons-pretender.js.es6 new file mode 100644 index 0000000..20ad640 --- /dev/null +++ b/test/javascripts/helpers/discourse-patrons-pretender.js.es6 @@ -0,0 +1,6 @@ + +export default function(helpers) { + const { response } = helpers; + + this.get("/patrons", () => response({ email: "hello@example.com" })) +} diff --git a/test/javascripts/helpers/stripe.js.es6 b/test/javascripts/helpers/stripe.js.es6 new file mode 100644 index 0000000..b202e8e --- /dev/null +++ b/test/javascripts/helpers/stripe.js.es6 @@ -0,0 +1,23 @@ + +export function stubStripe() { + window.Stripe = () => { + return { + createPaymentMethod() { + return new Ember.RSVP.Promise(resolve => { + resolve({}); + }); + }, + elements() { + return { + create() { + return { + on() {}, + card() {}, + mount() {} + }; + } + }; + } + }; + }; +}