From afbf23b776114c347deb8b370907ad50a49967df Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Mon, 27 Apr 2020 02:57:40 +0530 Subject: [PATCH] :white_check_mark: Add Stripe payments test --- src/init-tests.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/init-tests.ts b/src/init-tests.ts index daa4e518e..184869c09 100644 --- a/src/init-tests.ts +++ b/src/init-tests.ts @@ -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; @@ -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() { @@ -84,6 +94,7 @@ const runTests = async () => { RedisQueue, Database, Email, + Stripe, ElasticSearch, ]) { const testClass = new TestClass(); @@ -91,12 +102,19 @@ const runTests = async () => { 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)); + \ No newline at end of file