//@ts-nocheck import Chance from "chance"; import { MISSING_ACCOUNT_ID_ERROR_MESSAGE, MISSING_WALLET_ID_ERROR_MESSAGE, MISSING_WALLET_TRANSACTION_ID_ERROR_MESSAGE } from "../../constants"; import { testFetch } from "../../utils"; import walletFuctions from "./index"; import { defaultWalletTransactionsFilter } from "./models"; const wallets = walletFuctions(testFetch); const chance = new Chance(); describe("Wallets", () => { const accountID = chance.guid(); const walletID = chance.guid(); const transactionID = chance.guid(); describe("list wallets", () => { it("should error if no accountID", () => { return wallets.list({}).catch((resp) => { expect(resp.error).toEqual(MISSING_ACCOUNT_ID_ERROR_MESSAGE); }); }); it("should list wallets", () => { return wallets.list({ accountID }).then((resp) => { expect(resp.url).toEqual(`/accounts/${accountID}/wallets`); }); }); }); describe("get wallets", () => { it("should error if no accountID", () => { return wallets.list({ walletID }).catch((resp) => { expect(resp.error).toEqual(MISSING_ACCOUNT_ID_ERROR_MESSAGE); }); }); it("should error if no walletID", () => { return wallets.list({ accountID }).catch((resp) => { expect(resp.error).toEqual(MISSING_WALLET_ID_ERROR_MESSAGE); }); }); it("should get wallet", () => { wallets.get({ accountID, walletID }).then((resp) => { expect(resp.url).toEqual(`/accounts/${accountID}/wallets/${walletID}`); }); }); }); describe("list wallet transactions", () => { it("should error if no accountID", () => { return wallets.listTransactions({}).catch((resp) => { expect(resp.error).toEqual(MISSING_ACCOUNT_ID_ERROR_MESSAGE); }); }); it("should error if no walletID", () => { return wallets.listTransactions({ accountID }).catch((resp) => { expect(resp.error).toEqual(MISSING_WALLET_ID_ERROR_MESSAGE); }); }); it("should list wallet transactions", () => { return wallets.listTransactions({ accountID, walletID }).then((resp) => { expect(resp.url).toEqual( `/accounts/${accountID}/wallets/${walletID}/transactions?count=${defaultWalletTransactionsFilter.count}&skip=${defaultWalletTransactionsFilter.skip}` ); }); }); }); describe("get wallet transactions", () => { it("should error if no accountID", () => { return wallets.getTransaction({}).catch((resp) => { expect(resp.error).toEqual(MISSING_ACCOUNT_ID_ERROR_MESSAGE); }); }); it("should error if no walletID", () => { return wallets.getTransaction({ accountID }).catch((resp) => { expect(resp.error).toEqual(MISSING_WALLET_ID_ERROR_MESSAGE); }); }); it("should error if no transactionID", () => { return wallets.getTransaction({ accountID, walletID }).catch((resp) => { expect(resp.error).toEqual(MISSING_WALLET_TRANSACTION_ID_ERROR_MESSAGE); }); }); it("should get wallet transactions", () => { return wallets.getTransaction({ accountID, walletID, transactionID }).then((resp) => { expect(resp.url).toEqual( `/accounts/${accountID}/wallets/${walletID}/transactions/${transactionID}` ); }); }); }); });