stub stripe and add pretender

This commit is contained in:
Rimian Perkins 2019-10-09 11:53:58 +11:00
parent bde208ecb6
commit 2c6944e66e
4 changed files with 49 additions and 20 deletions

View File

@ -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");
});

View File

@ -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",

View File

@ -0,0 +1,6 @@
export default function(helpers) {
const { response } = helpers;
this.get("/patrons", () => response({ email: "hello@example.com" }))
}

View File

@ -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() {}
};
}
};
}
};
};
}