Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
✅ Add Stripe payments test
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Apr 26, 2020
1 parent fa63b49 commit afbf23b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/init-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { elasticSearchIndex } from "./helpers/elasticsearch";
import { receiveEmailMessage } from "./helpers/mail";
import { prisma } from "./helpers/prisma";
import { elasticSearchEnabled } from "@staart/elasticsearch";
import { getProductPricing } from "@staart/payments";

let numberOfFailedTests = 0;
interface Test {
name: string;
test(): Promise<void>;
Expand All @@ -35,6 +37,14 @@ class Database implements Test {
}
}

class Stripe implements Test {
name = "Stripe";
async test() {
const prices = await getProductPricing();
success(`Got ${prices.data.length} pricing plans`);
}
}

class Email implements Test {
name = "Email";
async test() {
Expand Down Expand Up @@ -84,19 +94,27 @@ const runTests = async () => {
RedisQueue,
Database,
Email,
Stripe,
ElasticSearch,
]) {
const testClass = new TestClass();
try {
await testClass.test();
success(testClass.name, "Test passed");
} catch (error) {
numberOfFailedTests += 1;
logError(testClass.name, "Test failed", 1);
console.log(error);
}
}
};

console.log();
runTests()
.then(() => success("All service tests passed"))
.then(() =>
numberOfFailedTests === 0
? success("All service tests passed")
: logError("Service tests", "All service tests passed", 1)
)
.catch((error) => console.log("ERROR", error));

0 comments on commit afbf23b

Please sign in to comment.