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

74 lines
1.9 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", {
2019-12-05 21:52:03 -05:00
template: `{{payment-options plans=plans}}`,
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
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,
"The none are selected"
);
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 options plan is selected", {
template: `{{payment-options plans=plans selectPlan=selectPlan}}`,
beforeEach() {},
async test(assert) {
assert.expect(1);
2019-12-08 20:01:10 -05:00
this.set("plans", [
{ currency: "aud", interval: "year", amountDollars: "44.99" },
{ currency: "gdp", interval: "month", amountDollars: "9.99" }
]);
2019-12-05 22:33:38 -05:00
this.set("selectPlan", function(plan) {
2019-12-08 20:01:10 -05:00
assert.equal(plan, this.get('plans.firstObject'), "the plan is selected");
2019-12-05 22:33:38 -05:00
});
await click(".btn-discourse-subscriptions-subscribe:first-child");
}
});