mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 07:12:46 +00:00
add specs back. fix plugin name
This commit is contained in:
parent
43fde60f3a
commit
dfba5471f9
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# name: Discourse Patrons
|
# name: discourse-patrons
|
||||||
# about: Integrates Stripe into Discourse to allow visitors to make payments
|
# about: Integrates Stripe into Discourse to allow visitors to make payments
|
||||||
# version: 1.0.0
|
# version: 1.0.0
|
||||||
# url: https://github.com/rimian/discourse-patrons
|
# url: https://github.com/rimian/discourse-patrons
|
||||||
|
47
test/javascripts/components/donation-form-test.es6
Normal file
47
test/javascripts/components/donation-form-test.es6
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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(".discourse-patrons-section-columns").length,
|
||||||
|
"The card section 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");
|
||||||
|
}
|
||||||
|
});
|
33
test/javascripts/components/donation-row-test.js.es6
Normal file
33
test/javascripts/components/donation-row-test.js.es6
Normal file
@ -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"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
40
test/javascripts/components/stripe-card-test.js.es6
Normal file
40
test/javascripts/components/stripe-card-test.js.es6
Normal file
@ -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({});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
elements() {
|
||||||
|
return {
|
||||||
|
create() {
|
||||||
|
return {
|
||||||
|
on() {},
|
||||||
|
card() {},
|
||||||
|
mount() {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
this.set("onSubmit", () => {
|
||||||
|
assert.ok(true, "payment method created");
|
||||||
|
});
|
||||||
|
|
||||||
|
await click(".btn-payment");
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user