discourse-subscriptions/test/javascripts/components/payment-options-test.js.es6

99 lines
2.6 KiB
Plaintext
Raw Normal View History

2019-12-05 21:52:03 -05:00
import componentTest from "helpers/component-test";
moduleForComponent("payment-options", { integration: true });
2019-12-05 22:33:38 -05:00
componentTest("Discourse Subscriptions payment options have no plans", {
2019-12-05 21:52:03 -05:00
template: `{{payment-options plans=plans}}`,
async test(assert) {
2019-12-05 22:33:38 -05:00
this.set("plans", false);
2019-12-05 21:52:03 -05:00
assert.equal(
2019-12-05 22:33:38 -05:00
find(".btn-discourse-subscriptions-subscribe").length,
2019-12-05 21:52:03 -05:00
0,
"The plan buttons are not shown"
);
}
});
2019-12-05 22:33:38 -05:00
componentTest("Discourse Subscriptions payment options has content", {
template: `{{payment-options plans=plans planTypeIsSelected=planTypeIsSelected}}`,
2019-12-05 21:52:03 -05:00
async test(assert) {
2019-12-08 18:30:34 -05:00
this.set("plans", [
2019-12-08 20:01:10 -05:00
{ currency: "aud", interval: "year", amountDollars: "44.99" },
{ currency: "gdp", interval: "month", amountDollars: "9.99" }
2019-12-08 18:30:34 -05:00
]);
2019-12-05 21:52:03 -05:00
this.set("planTypeIsSelected", true);
2019-12-11 20:59:26 -05:00
assert.equal(
find(".btn-discourse-subscriptions-payment-type").length,
2,
"The payment type buttons are shown"
);
2019-12-05 21:52:03 -05:00
assert.equal(
2019-12-05 22:33:38 -05:00
find(".btn-discourse-subscriptions-subscribe").length,
2019-12-05 21:52:03 -05:00
2,
"The plan buttons are shown"
);
assert.equal(
find("#subscribe-buttons .btn-primary").length,
0,
2019-12-11 20:59:26 -05:00
"No plan buttons are selected by default"
2019-12-05 21:52:03 -05:00
);
2019-12-08 18:30:34 -05:00
assert.equal(
2019-12-08 20:01:10 -05:00
find(".btn-discourse-subscriptions-subscribe:first-child .interval")
.text()
.trim(),
"Yearly",
2019-12-08 18:30:34 -05:00
"The plan interval is shown"
);
assert.equal(
2019-12-08 20:01:10 -05:00
find(".btn-discourse-subscriptions-subscribe:first-child .amount")
.text()
.trim(),
2019-12-08 18:30:34 -05:00
"$AUD 44.99",
"The plan amount and currency is shown"
);
2019-12-05 21:52:03 -05:00
}
});
2019-12-05 22:33:38 -05:00
componentTest("Discourse Subscriptions payment type plan", {
template: `{{payment-options plans=plans planTypeIsSelected=planTypeIsSelected}}`,
2019-12-05 22:33:38 -05:00
async test(assert) {
2019-12-08 20:01:10 -05:00
this.set("plans", [
{ currency: "aud", interval: "year", amountDollars: "44.99" }
2019-12-08 20:01:10 -05:00
]);
2019-12-05 22:33:38 -05:00
this.set("planTypeIsSelected", true);
2019-12-09 18:15:30 -05:00
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"
);
2019-12-05 22:33:38 -05:00
}
});