REFACTOR: Use the new format for acceptance tests. (#37)

This commit is contained in:
Roman Rizzi 2021-01-04 16:32:33 -03:00 committed by GitHub
parent 0b5f740db5
commit 088b8d2239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 50 deletions

View File

@ -1,17 +1,16 @@
import { acceptance } from "helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
acceptance("Discourse Subscriptions", {
beforeEach() {
acceptance("Discourse Subscriptions", function (needs) {
needs.user();
needs.hooks.beforeEach(() => {
stubStripe();
},
});
loggedIn: true
});
QUnit.test("viewing product page", async assert => {
test("viewing product page", async (assert) => {
await visit("/s");
assert.ok($(".product-list").length, "has product page");
assert.ok($(".product:first-child a").length, "has a link");
});
});

View File

@ -1,15 +1,13 @@
import { acceptance } from "helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
acceptance("Discourse Subscriptions", {
beforeEach() {
acceptance("Discourse Subscriptions", function (needs) {
needs.user();
needs.hooks.beforeEach(() => {
stubStripe();
},
});
loggedIn: true
});
QUnit.test("subscribing", async assert => {
test("subscribing", async (assert) => {
await visit("/s");
await click(".product:first-child a");
@ -19,5 +17,9 @@ QUnit.test("subscribing", async assert => {
"has the sections for billing"
);
assert.ok($(".subscribe-buttons button").length, "has buttons for subscribe");
assert.ok(
$(".subscribe-buttons button").length,
"has buttons for subscribe"
);
});
});

View File

@ -1,4 +1,4 @@
import componentTest from "helpers/component-test";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("payment-options", { integration: true });
@ -13,7 +13,7 @@ componentTest("Discourse Subscriptions payment options have no plans", {
0,
"The plan buttons are not shown"
);
}
},
});
componentTest("Discourse Subscriptions payment options has content", {
@ -27,17 +27,17 @@ componentTest("Discourse Subscriptions payment options has content", {
{
currency: "aud",
recurring: { interval: "year" },
amountDollars: "44.99"
amountDollars: "44.99",
},
{
currency: "gdp",
recurring: { interval: "month" },
amountDollars: "9.99"
}
amountDollars: "9.99",
},
]);
},
async test(assert) {
assert.equal(this.selectedPlan, null, "No plans are selected by default");
}
},
});

View File

@ -1,4 +1,4 @@
import componentTest from "helpers/component-test";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("payment-plan", { integration: true });
@ -13,7 +13,7 @@ componentTest("Payment plan subscription button rendered", {
type: "recurring",
currency: "aud",
recurring: { interval: "year" },
amountDollars: "44.99"
amountDollars: "44.99",
});
},
@ -39,7 +39,7 @@ componentTest("Payment plan subscription button rendered", {
"$AUD 44.99",
"The plan amount and currency is shown"
);
}
},
});
componentTest("Payment plan one-time-payment button rendered", {
@ -52,7 +52,7 @@ componentTest("Payment plan one-time-payment button rendered", {
this.set("plan", {
type: "one_time",
currency: "USD",
amountDollars: "3.99"
amountDollars: "3.99",
});
},
@ -64,5 +64,5 @@ componentTest("Payment plan one-time-payment button rendered", {
"One-Time Payment",
"Shown as one time payment"
);
}
},
});

View File

@ -4,7 +4,7 @@ export function stubStripe() {
window.Stripe = () => {
return {
createPaymentMethod() {
return new Promise(resolve => {
return new Promise((resolve) => {
resolve({});
});
},
@ -14,11 +14,11 @@ export function stubStripe() {
return {
on() {},
card() {},
mount() {}
mount() {},
};
}
},
};
}
},
};
};
}

View File

@ -2,13 +2,13 @@ import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/pla
QUnit.module("discourse-patrons:model:plan");
QUnit.test("subscriptionRate", assert => {
QUnit.test("subscriptionRate", (assert) => {
const plan = Plan.create({
unit_amount: "2399",
currency: "aud",
recurring: {
interval: "month"
}
interval: "month",
},
});
assert.equal(
@ -18,7 +18,7 @@ QUnit.test("subscriptionRate", assert => {
);
});
QUnit.test("amountDollars", assert => {
QUnit.test("amountDollars", (assert) => {
const plan = Plan.create({ unit_amount: 2399 });
assert.equal(
@ -28,7 +28,7 @@ QUnit.test("amountDollars", assert => {
);
});
QUnit.test("amount", assert => {
QUnit.test("amount", (assert) => {
const plan = Plan.create({ amountDollars: "22.12" });
assert.equal(plan.get("unit_amount"), 2212, "it returns the cents amount");