mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 02:05:26 +08:00
42 lines
1.1 KiB
JavaScript
Vendored
42 lines
1.1 KiB
JavaScript
Vendored
import { module, test } from "qunit";
|
|
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
|
|
|
module("Unit | Model | plan", function () {
|
|
test("subscriptionRate", function (assert) {
|
|
const plan = Plan.create({
|
|
unit_amount: "2399",
|
|
currency: "aud",
|
|
recurring: {
|
|
interval: "month",
|
|
},
|
|
});
|
|
|
|
assert.strictEqual(
|
|
plan.get("subscriptionRate"),
|
|
"23.99 AUD / month",
|
|
"it returns the formatted subscription rate"
|
|
);
|
|
});
|
|
|
|
test("amountDollars", function (assert) {
|
|
const plan = Plan.create({ unit_amount: 2399 });
|
|
|
|
assert.strictEqual(
|
|
plan.get("amountDollars"),
|
|
"23.99",
|
|
"it returns the formatted dollar amount"
|
|
);
|
|
});
|
|
|
|
test("amount", function (assert) {
|
|
const plan = Plan.create({ amountDollars: "22.12" });
|
|
|
|
assert.strictEqual(plan.get("unit_amount"), 2212);
|
|
});
|
|
|
|
test("amount with floating point edge case", function (assert) {
|
|
const plan = Plan.create({ amountDollars: "19.99" });
|
|
|
|
assert.strictEqual(plan.get("unit_amount"), 1999);
|
|
});
|
|
});
|