1
0
mirror of synced 2026-08-04 14:16:55 +00:00

initial components

This commit is contained in:
Rimian Perkins
2019-09-11 20:19:50 +10:00
parent af97581911
commit ee2be672f7
11 changed files with 465 additions and 0 deletions
@@ -0,0 +1,45 @@
import componentTest from "helpers/component-test";
moduleForComponent("donation-form", { integration: true });
componentTest("Discourse Patrons donation form has content", {
template: `{{donation-form}}`,
beforeEach() {
this.registry.register(
"component:stripe-card",
Ember.Component.extend({ tagName: "dummy-component-tag" })
);
},
async test(assert) {
assert.ok(find("#payment-form").length, "The form renders");
assert.ok(
find("dummy-component-tag").length,
"The stripe component renders"
);
}
});
componentTest("donation form has a confirmation", {
template: `{{donation-form confirmation=confirmation}}`,
beforeEach() {
this.registry.register(
"component:stripe-card",
Ember.Component.extend()
);
},
async test(assert) {
this.set("confirmation", { "card": { "last4": "4242" }});
const confirmExists = find(".discourse-donations-confirmation").length;
assert.ok(confirmExists, "The confirmation form renders");
const last4 = find(".discourse-donations-last4").text().trim();
assert.equal(last4, ".... .... .... 4242", "The last 4 digits are correct");
}
});
@@ -0,0 +1,33 @@
import componentTest from "helpers/component-test";
moduleForComponent("donation-row", { integration: true });
componentTest("Discourse Patrons donation-row", {
template: `{{donation-row currency=3 amount=21 period='monthly'}}`,
test(assert) {
assert.equal(find(".donation-row-currency").text(), "3", "It has currency");
assert.equal(find(".donation-row-amount").text(), "21", "It has an amount");
assert.equal(
find(".donation-row-period").text(),
"monthly",
"It has a period"
);
}
});
componentTest("donation-row cancels subscription", {
template: `{{donation-row currentUser=currentUser subscription=subscription}}`,
beforeEach() {
this.set("currentUser", true);
this.set("subscription", true);
},
async test(assert) {
assert.ok(
find(".donation-row-subscription").length,
"It has a subscription"
);
}
});
@@ -0,0 +1,40 @@
import componentTest from "helpers/component-test";
moduleForComponent("stripe-card", { integration: true });
componentTest("Discourse Patrons stripe card success", {
template: `{{stripe-card handleConfirmStripeCard=onSubmit}}`,
beforeEach() {
window.Stripe = () => {
return {
createPaymentMethod() {
return new Ember.RSVP.Promise((resolve) => {
resolve('payment-method-response');
});
},
elements() {
return {
create() {
return {
on() {},
card() {},
mount() {},
};
},
};
},
};
};
},
async test(assert) {
assert.expect(1);
this.set("onSubmit", (arg) => {
assert.equal(arg, "payment-method-response", "payment method created");
});
await click(".btn-payment");
},
});