DEV: Fix imports (#113)
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
|
||||
acceptance("Discourse Subscriptions", function (needs) {
|
||||
needs.user();
|
||||
needs.hooks.beforeEach(() => {
|
||||
needs.hooks.beforeEach(function () {
|
||||
stubStripe();
|
||||
});
|
||||
|
||||
test("viewing product page", async (assert) => {
|
||||
test("viewing product page", async function (assert) {
|
||||
await visit("/s");
|
||||
|
||||
assert.ok($(".product-list").length, "has product page");
|
||||
assert.ok($(".product:first-child a").length, "has a link");
|
||||
assert.ok(count(".product-list") > 0, "has product page");
|
||||
assert.ok(count(".product:first-child a") > 0, "has a link");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
|
||||
acceptance("Discourse Subscriptions", function (needs) {
|
||||
needs.user();
|
||||
needs.hooks.beforeEach(() => {
|
||||
needs.hooks.beforeEach(function () {
|
||||
stubStripe();
|
||||
});
|
||||
|
||||
test("subscribing", async (assert) => {
|
||||
test("subscribing", async function (assert) {
|
||||
await visit("/s");
|
||||
|
||||
await click(".product:first-child a");
|
||||
|
||||
assert.ok(
|
||||
$(".discourse-subscriptions-section-columns").length,
|
||||
count(".discourse-subscriptions-section-columns") > 0,
|
||||
"has the sections for billing"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
$(".subscribe-buttons button").length,
|
||||
count(".subscribe-buttons button") > 0,
|
||||
"has buttons for subscribe"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import componentTest from "discourse/tests/helpers/component-test";
|
||||
|
||||
moduleForComponent("payment-options", { integration: true });
|
||||
|
||||
componentTest("Discourse Subscriptions payment options have no plans", {
|
||||
template: `{{payment-options plans=plans}}`,
|
||||
|
||||
async test(assert) {
|
||||
this.set("plans", false);
|
||||
|
||||
assert.equal(
|
||||
find(".btn-discourse-subscriptions-subscribe").length,
|
||||
0,
|
||||
"The plan buttons are not shown"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("Discourse Subscriptions payment options has content", {
|
||||
template: `{{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.equal(this.selectedPlan, null, "No plans are selected by default");
|
||||
},
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
import componentTest from "discourse/tests/helpers/component-test";
|
||||
|
||||
moduleForComponent("payment-plan", { integration: true });
|
||||
|
||||
componentTest("Payment plan subscription button rendered", {
|
||||
template: `{{payment-plan
|
||||
plan=plan
|
||||
selectedPlan=selectedPlan
|
||||
}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("plan", {
|
||||
type: "recurring",
|
||||
currency: "aud",
|
||||
recurring: { interval: "year" },
|
||||
amountDollars: "44.99",
|
||||
});
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
find(".btn-discourse-subscriptions-subscribe").length,
|
||||
1,
|
||||
"The payment button is shown"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find(".btn-discourse-subscriptions-subscribe:first-child .interval")
|
||||
.text()
|
||||
.trim(),
|
||||
"Yearly",
|
||||
"The plan interval is shown -- Yearly"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find(".btn-discourse-subscriptions-subscribe:first-child .amount")
|
||||
.text()
|
||||
.trim(),
|
||||
"$44.99",
|
||||
"The plan amount and currency is shown"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("Payment plan one-time-payment button rendered", {
|
||||
template: `{{payment-plan
|
||||
plan=plan
|
||||
selectedPlan=selectedPlan
|
||||
}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("plan", {
|
||||
type: "one_time",
|
||||
currency: "USD",
|
||||
amountDollars: "3.99",
|
||||
});
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
find(".btn-discourse-subscriptions-subscribe:first-child .interval")
|
||||
.text()
|
||||
.trim(),
|
||||
"One-Time Payment",
|
||||
"Shown as one time payment"
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { count, discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
|
||||
discourseModule("payment-options", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("Discourse Subscriptions payment options have no plans", {
|
||||
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"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("Discourse Subscriptions payment options has content", {
|
||||
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"
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import {
|
||||
count,
|
||||
discourseModule,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
|
||||
discourseModule("payment-plan", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("Payment plan subscription button rendered", {
|
||||
template: hbs`{{payment-plan
|
||||
plan=plan
|
||||
selectedPlan=selectedPlan
|
||||
}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("plan", {
|
||||
type: "recurring",
|
||||
currency: "aud",
|
||||
recurring: { interval: "year" },
|
||||
amountDollars: "44.99",
|
||||
});
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.strictEqual(
|
||||
count(".btn-discourse-subscriptions-subscribe"),
|
||||
1,
|
||||
"The payment button is shown"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".btn-discourse-subscriptions-subscribe:first-child .interval"
|
||||
).innerText.trim(),
|
||||
"Yearly",
|
||||
"The plan interval is shown -- Yearly"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".btn-discourse-subscriptions-subscribe:first-child .amount"
|
||||
).innerText.trim(),
|
||||
"$44.99",
|
||||
"The plan amount and currency is shown"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("Payment plan one-time-payment button rendered", {
|
||||
template: hbs`{{payment-plan
|
||||
plan=plan
|
||||
selectedPlan=selectedPlan
|
||||
}}`,
|
||||
|
||||
beforeEach() {
|
||||
this.set("plan", {
|
||||
type: "one_time",
|
||||
currency: "USD",
|
||||
amountDollars: "3.99",
|
||||
});
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".btn-discourse-subscriptions-subscribe:first-child .interval"
|
||||
).innerText.trim(),
|
||||
"One-Time Payment",
|
||||
"Shown as one time payment"
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1,35 +1,40 @@
|
||||
import { module, test } from "qunit";
|
||||
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
||||
|
||||
QUnit.module("discourse-patrons:model:plan");
|
||||
module("discourse-patrons:model:plan", function () {
|
||||
test("subscriptionRate", function (assert) {
|
||||
const plan = Plan.create({
|
||||
unit_amount: "2399",
|
||||
currency: "aud",
|
||||
recurring: {
|
||||
interval: "month",
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("subscriptionRate", (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"
|
||||
);
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
plan.get("subscriptionRate"),
|
||||
"23.99 AUD / month",
|
||||
"it returns the formatted subscription rate"
|
||||
);
|
||||
});
|
||||
test("amountDollars", function (assert) {
|
||||
const plan = Plan.create({ unit_amount: 2399 });
|
||||
|
||||
QUnit.test("amountDollars", (assert) => {
|
||||
const plan = Plan.create({ unit_amount: 2399 });
|
||||
assert.strictEqual(
|
||||
plan.get("amountDollars"),
|
||||
"23.99",
|
||||
"it returns the formatted dollar amount"
|
||||
);
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
plan.get("amountDollars"),
|
||||
23.99,
|
||||
"it returns the formatted dollar amount"
|
||||
);
|
||||
});
|
||||
test("amount", function (assert) {
|
||||
const plan = Plan.create({ amountDollars: "22.12" });
|
||||
|
||||
QUnit.test("amount", (assert) => {
|
||||
const plan = Plan.create({ amountDollars: "22.12" });
|
||||
|
||||
assert.equal(plan.get("unit_amount"), 2212, "it returns the cents amount");
|
||||
assert.strictEqual(
|
||||
plan.get("unit_amount"),
|
||||
2212,
|
||||
"it returns the cents amount"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user