2024-01-16 11:51:44 -05:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
2022-03-06 18:30:01 -05:00
|
|
|
import componentTest, {
|
|
|
|
setupRenderingTest,
|
|
|
|
} from "discourse/tests/helpers/component-test";
|
2024-01-16 11:51:44 -05:00
|
|
|
import { count, discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
2022-03-06 18:30:01 -05:00
|
|
|
|
2024-09-17 19:49:28 -04:00
|
|
|
discourseModule("Subscriptions | payment-options", function (hooks) {
|
2022-03-06 18:30:01 -05:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2024-09-17 19:49:28 -04:00
|
|
|
componentTest("payment options have no plans", {
|
2022-03-06 18:30:01 -05:00
|
|
|
template: hbs`{{payment-options plans=plans}}`,
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
this.set("plans", false);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
count(".btn-discourse-subscriptions-subscribe"),
|
|
|
|
0,
|
|
|
|
"The plan buttons are not shown"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-09-17 19:49:28 -04:00
|
|
|
componentTest("payment options has content", {
|
2022-03-06 18:30:01 -05:00
|
|
|
template: hbs`{{payment-options
|
|
|
|
plans=plans
|
|
|
|
selectedPlan=selectedPlan
|
|
|
|
}}`,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.set("plans", [
|
|
|
|
{
|
|
|
|
currency: "aud",
|
|
|
|
recurring: { interval: "year" },
|
|
|
|
amountDollars: "44.99",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
currency: "gdp",
|
|
|
|
recurring: { interval: "month" },
|
|
|
|
amountDollars: "9.99",
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
assert.strictEqual(
|
|
|
|
this.selectedPlan,
|
|
|
|
undefined,
|
|
|
|
"No plans are selected by default"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|