2022-03-06 18:30:01 -05:00
|
|
|
import { module, test } from "qunit";
|
2019-12-02 19:00:03 -05:00
|
|
|
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
2019-10-30 19:44:46 -04:00
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
module("discourse-patrons:model:plan", function () {
|
|
|
|
test("subscriptionRate", function (assert) {
|
|
|
|
const plan = Plan.create({
|
|
|
|
unit_amount: "2399",
|
|
|
|
currency: "aud",
|
|
|
|
recurring: {
|
|
|
|
interval: "month",
|
|
|
|
},
|
|
|
|
});
|
2019-10-30 19:44:46 -04:00
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
assert.strictEqual(
|
|
|
|
plan.get("subscriptionRate"),
|
|
|
|
"23.99 AUD / month",
|
|
|
|
"it returns the formatted subscription rate"
|
|
|
|
);
|
2019-10-30 19:44:46 -04:00
|
|
|
});
|
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
test("amountDollars", function (assert) {
|
|
|
|
const plan = Plan.create({ unit_amount: 2399 });
|
2019-10-30 20:41:01 -04:00
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
assert.strictEqual(
|
|
|
|
plan.get("amountDollars"),
|
|
|
|
"23.99",
|
|
|
|
"it returns the formatted dollar amount"
|
|
|
|
);
|
|
|
|
});
|
2019-10-30 22:29:11 -04:00
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
test("amount", function (assert) {
|
|
|
|
const plan = Plan.create({ amountDollars: "22.12" });
|
2019-10-30 22:29:11 -04:00
|
|
|
|
2022-03-06 18:30:01 -05:00
|
|
|
assert.strictEqual(
|
|
|
|
plan.get("unit_amount"),
|
|
|
|
2212,
|
|
|
|
"it returns the cents amount"
|
|
|
|
);
|
|
|
|
});
|
2019-10-30 19:44:46 -04:00
|
|
|
});
|