buttons for selecting price and one time payment

This commit is contained in:
Rimian Perkins
2019-12-13 10:41:14 +11:00
parent e27b55ea6f
commit 57fb508514
13 changed files with 264 additions and 90 deletions
@@ -18,7 +18,7 @@ componentTest("Discourse Subscriptions payment options have no plans", {
});
componentTest("Discourse Subscriptions payment options has content", {
template: `{{payment-options plans=plans}}`,
template: `{{payment-options plans=plans planTypeIsSelected=planTypeIsSelected}}`,
async test(assert) {
this.set("plans", [
@@ -26,21 +26,8 @@ componentTest("Discourse Subscriptions payment options has content", {
{ currency: "gdp", interval: "month", amountDollars: "9.99" }
]);
assert.equal(
find(".btn-discourse-subscriptions-payment-type").length,
2,
"The payment type buttons are shown"
);
assert.equal(
find("#discourse-subscriptions-payment-type-plan.btn-primary").length,
1,
"The plan payment type button is selected"
);
assert.equal(
find("#discourse-subscriptions-payment-type-payment.btn-primary").length,
0,
"The single payment type button is not selected"
);
this.set("planTypeIsSelected", true);
assert.equal(
find(".btn-discourse-subscriptions-payment-type").length,
2,
@@ -73,22 +60,40 @@ componentTest("Discourse Subscriptions payment options has content", {
}
});
componentTest("Discourse Subscriptions payment options plan is selected", {
template: `{{payment-options plans=plans}}`,
beforeEach() {},
componentTest("Discourse Subscriptions payment type plan", {
template: `{{payment-options plans=plans planTypeIsSelected=planTypeIsSelected}}`,
async test(assert) {
this.set("plans", [
EmberObject.create({
currency: "aud",
interval: "year",
amountDollars: "44.99"
})
{ currency: "aud", interval: "year", amountDollars: "44.99" }
]);
await click(".btn-discourse-subscriptions-subscribe:first-child");
this.set("planTypeIsSelected", true);
assert.ok(this.get("plans.firstObject.selected"), "it selected the plan");
assert.equal(
find("#discourse-subscriptions-payment-type-plan.btn-primary").length,
1,
"The plan type button is selected"
);
assert.equal(
find("#discourse-subscriptions-payment-type-payment.btn-primary").length,
0,
"The payment type button is not selected"
);
await click("#discourse-subscriptions-payment-type-payment");
assert.equal(
find("#discourse-subscriptions-payment-type-plan.btn-primary").length,
0,
"The plan type button is selected"
);
assert.equal(
find("#discourse-subscriptions-payment-type-payment.btn-primary").length,
1,
"The payment type button is not selected"
);
}
});