fix: currency conversion utils for non decimal currencies like JPY
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
import { AutumnInt } from "@/external/autumn/autumnCli.js";
|
||||
import { initCustomer } from "@/utils/scriptUtils/initCustomer.js";
|
||||
import { expect } from "chai";
|
||||
import chalk from "chalk";
|
||||
import { setupBefore } from "tests/before.js";
|
||||
import { AutumnCli } from "tests/cli/AutumnCli.js";
|
||||
import { features, products } from "tests/global.js";
|
||||
import { compareMainProduct } from "tests/utils/compare.js";
|
||||
import { completeCheckoutForm } from "tests/utils/stripeUtils.js";
|
||||
import { timeout } from "tests/utils/genUtils.js";
|
||||
import { constructRawProduct } from "@/utils/scriptUtils/createTestProducts.js";
|
||||
import { constructPrepaidItem } from "@/utils/scriptUtils/constructItem.js";
|
||||
import { createProducts } from "tests/utils/productUtils.js";
|
||||
import { completeCheckoutForm } from "tests/utils/stripeUtils.js";
|
||||
import { AutumnInt } from "@/external/autumn/autumnCli.js";
|
||||
import { constructPrepaidItem } from "@/utils/scriptUtils/constructItem.js";
|
||||
import { constructRawProduct } from "@/utils/scriptUtils/createTestProducts.js";
|
||||
import { initCustomer } from "@/utils/scriptUtils/initCustomer.js";
|
||||
|
||||
// const oneTimeQuantity = 2;
|
||||
// const oneTimePurchaseCount = 2;
|
||||
// const oneTimeOverrideQuantity = 4;
|
||||
// const monthlyQuantity = 2;
|
||||
let oneTimeItem = constructPrepaidItem({
|
||||
const oneTimeItem = constructPrepaidItem({
|
||||
featureId: features.metered1.id,
|
||||
price: 9,
|
||||
billingUnits: 250,
|
||||
isOneOff: true,
|
||||
});
|
||||
|
||||
let oneTime = constructRawProduct({
|
||||
const oneTime = constructRawProduct({
|
||||
id: "basic3_one_off",
|
||||
items: [oneTimeItem],
|
||||
isAddOn: true,
|
||||
});
|
||||
|
||||
let monthlyItem = constructPrepaidItem({
|
||||
const monthlyItem = constructPrepaidItem({
|
||||
featureId: features.metered1.id,
|
||||
price: 9,
|
||||
billingUnits: 250,
|
||||
});
|
||||
|
||||
let monthly = constructRawProduct({
|
||||
const monthly = constructRawProduct({
|
||||
id: "basic3_monthly",
|
||||
items: [
|
||||
constructPrepaidItem({
|
||||
@@ -49,8 +49,8 @@ let monthly = constructRawProduct({
|
||||
// UNCOMMENT FROM HERE
|
||||
const testCase = "basic3";
|
||||
describe(`${chalk.yellowBright("basic3: Testing attach one time / monthly add ons")}`, () => {
|
||||
let customerId = testCase;
|
||||
let autumn: AutumnInt = new AutumnInt();
|
||||
const customerId = testCase;
|
||||
const autumn: AutumnInt = new AutumnInt();
|
||||
let db, org, env;
|
||||
|
||||
before(async function () {
|
||||
@@ -77,7 +77,7 @@ describe(`${chalk.yellowBright("basic3: Testing attach one time / monthly add on
|
||||
});
|
||||
});
|
||||
|
||||
it("should attach pro", async function () {
|
||||
it("should attach pro", async () => {
|
||||
await autumn.attach({
|
||||
customer_id: customerId,
|
||||
product_id: products.pro.id,
|
||||
@@ -94,7 +94,7 @@ describe(`${chalk.yellowBright("basic3: Testing attach one time / monthly add on
|
||||
const oneTimeBillingUnits = oneTimeItem.billing_units;
|
||||
const oneTimePurchaseCount = 2;
|
||||
|
||||
it("should attach one time add on twice, force checkout", async function () {
|
||||
it("should attach one time add on twice, force checkout", async () => {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const res = await autumn.attach({
|
||||
customer_id: customerId,
|
||||
@@ -110,13 +110,13 @@ describe(`${chalk.yellowBright("basic3: Testing attach one time / monthly add on
|
||||
}
|
||||
});
|
||||
|
||||
it("should have correct product & entitlements", async function () {
|
||||
it("should have correct product & entitlements", async () => {
|
||||
const cusRes = await AutumnCli.getCustomer(customerId);
|
||||
|
||||
const addOnBalance = cusRes.entitlements.find(
|
||||
(e: any) =>
|
||||
e.feature_id === features.metered1.id &&
|
||||
e.interval ==
|
||||
e.interval ===
|
||||
products.oneTimeAddOnMetered1.entitlements.metered1.interval,
|
||||
);
|
||||
|
||||
@@ -141,7 +141,7 @@ describe(`${chalk.yellowBright("basic3: Testing attach one time / monthly add on
|
||||
);
|
||||
});
|
||||
|
||||
it("should have correct /check result for metered1", async function () {
|
||||
it("should have correct /check result for metered1", async () => {
|
||||
const res: any = await AutumnCli.entitled(customerId, features.metered1.id);
|
||||
|
||||
expect(res!.allowed).to.be.true;
|
||||
|
||||
Reference in New Issue
Block a user