DEV: Prefix all test names (#238)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { module, test } from "qunit";
|
||||
import { formatCurrency } from "discourse/plugins/discourse-subscriptions/discourse/helpers/format-currency";
|
||||
|
||||
module("Subscriptions | Unit | Helper | format-currency", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("it formats USD correctly", function (assert) {
|
||||
let result = formatCurrency(["USD", 338.2]);
|
||||
assert.equal(result, "$338.20", "Formats USD correctly");
|
||||
});
|
||||
|
||||
test("it rounds correctly", function (assert) {
|
||||
let result = formatCurrency(["USD", 338.289]);
|
||||
assert.equal(result, "$338.29", "Rounds correctly");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { module, test } from "qunit";
|
||||
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
||||
|
||||
module("Subscriptions | 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,
|
||||
"it returns the cents amount"
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user