Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to rn73 #3181

Merged
merged 6 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
11 changes: 5 additions & 6 deletions __tests__/hooks/use-display-currency.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ const wrapWithMocks =


(mocks) =>
({ children }: PropsWithChildren) =>
(
<IsAuthedContextProvider value={true}>
<MockedProvider mocks={mocks}>{children}</MockedProvider>
</IsAuthedContextProvider>
)
({ children }: PropsWithChildren) => (
<IsAuthedContextProvider value={true}>
<MockedProvider mocks={mocks}>{children}</MockedProvider>
</IsAuthedContextProvider>
)

describe("usePriceConversion", () => {
describe("testing moneyAmountToMajorUnitOrSats", () => {
Expand Down
35 changes: 15 additions & 20 deletions __tests__/payment-details/amount-lightning-payment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
createGetFeeMocks,
createSendPaymentMocks,
expectDestinationSpecifiedMemoCannotSetMemo,
getTestSetMemo,
getTestSetSendingWalletDescriptor,
usdSendingWalletDescriptor,
} from "./helpers"

Expand All @@ -21,15 +19,9 @@ const defaultParams: PaymentDetails.CreateAmountLightningPaymentDetailsParams<Wa
sendingWalletDescriptor: btcSendingWalletDescriptor,
}

const spy = jest.spyOn(PaymentDetails, "createAmountLightningPaymentDetails")

describe("amount lightning payment details", () => {
const { createAmountLightningPaymentDetails } = PaymentDetails

beforeEach(() => {
spy.mockClear()
})

it("properly sets fields with all arguments provided", () => {
const paymentDetails = createAmountLightningPaymentDetails(defaultParams)
expect(paymentDetails).toEqual(
Expand Down Expand Up @@ -168,20 +160,23 @@ describe("amount lightning payment details", () => {
})

it("can set memo if no memo provided", () => {
const testSetMemo = getTestSetMemo()
testSetMemo({
defaultParams,
spy,
creatorFunction: createAmountLightningPaymentDetails,
})
const paymentDetails = createAmountLightningPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})

it("can set sending wallet descriptor", () => {
const testSetSendingWalletDescriptor = getTestSetSendingWalletDescriptor()
testSetSendingWalletDescriptor({
defaultParams,
spy,
creatorFunction: createAmountLightningPaymentDetails,
})
const paymentDetails = createAmountLightningPaymentDetails(defaultParams)
const sendingWalletDescriptor = {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
35 changes: 15 additions & 20 deletions __tests__/payment-details/amount-onchain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
createGetFeeMocks,
createSendPaymentMocks,
expectDestinationSpecifiedMemoCannotSetMemo,
getTestSetMemo,
getTestSetSendingWalletDescriptor,
testAmount,
usdSendingWalletDescriptor,
} from "./helpers"
Expand All @@ -21,15 +19,9 @@ const defaultParams: PaymentDetails.CreateAmountOnchainPaymentDetailsParams<Wall
sendingWalletDescriptor: btcSendingWalletDescriptor,
}

const spy = jest.spyOn(PaymentDetails, "createAmountOnchainPaymentDetails")

describe("no amount onchain payment details", () => {
const { createAmountOnchainPaymentDetails } = PaymentDetails

beforeEach(() => {
spy.mockClear()
})

it("properly sets fields with all arguments provided", () => {
const paymentDetails = createAmountOnchainPaymentDetails(defaultParams)
expect(paymentDetails).toEqual(
Expand Down Expand Up @@ -174,20 +166,23 @@ describe("no amount onchain payment details", () => {
})

it("can set memo if no memo provided", () => {
const testSetMemo = getTestSetMemo()
testSetMemo({
defaultParams,
spy,
creatorFunction: createAmountOnchainPaymentDetails,
})
const paymentDetails = createAmountOnchainPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})

it("can set sending wallet descriptor", () => {
const testSetSendingWalletDescriptor = getTestSetSendingWalletDescriptor()
testSetSendingWalletDescriptor({
defaultParams,
spy,
creatorFunction: createAmountOnchainPaymentDetails,
})
const paymentDetails = createAmountOnchainPaymentDetails(defaultParams)
const sendingWalletDescriptor = {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
50 changes: 0 additions & 50 deletions __tests__/payment-details/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ export const usdSendingWalletDescriptor = {
id: "testwallet",
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type CreateFunctionWithSpyParams<T extends (...args: any) => any> = {
spy: jest.SpyInstance<ReturnType<T>, Parameters<T>>
defaultParams: Parameters<T>
creatorFunction: T
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type CreateFunctionWithSpy = <T extends (...args: any) => any>() => (
params: CreateFunctionWithSpyParams<T>,
) => void

export const expectDestinationSpecifiedMemoCannotSetMemo = <T extends WalletCurrency>(
paymentDetails: PaymentDetail<T>,
destinationSpecifiedMemo: string,
Expand All @@ -70,44 +58,6 @@ export const expectCannotSendPayment = (
expect(paymentDetails.sendPaymentMutation).toBeUndefined()
}

export const getTestSetMemo: CreateFunctionWithSpy = () => (params) => {
const { defaultParams, creatorFunction, spy } = params
const senderSpecifiedMemo = "sender memo"
const paymentDetails = creatorFunction(defaultParams)

if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")
paymentDetails.setMemo(senderSpecifiedMemo)

const lastCall = spy.mock.lastCall && spy.mock.lastCall[0]
expect(lastCall).toEqual({ ...defaultParams, senderSpecifiedMemo })
}

export const getTestSetAmount: CreateFunctionWithSpy = () => (params) => {
const { defaultParams, creatorFunction, spy } = params
const paymentDetails = creatorFunction(defaultParams)
const unitOfAccountAmount = {
amount: 100,
currency: WalletCurrency.Btc,
}
if (!paymentDetails.canSetAmount) throw new Error("Amount is unable to be set")
paymentDetails.setAmount(unitOfAccountAmount)
const lastCall = spy.mock.lastCall && spy.mock.lastCall[0]
expect(lastCall).toEqual({ ...defaultParams, unitOfAccountAmount })
}

export const getTestSetSendingWalletDescriptor: CreateFunctionWithSpy =
() => (params) => {
const { defaultParams, creatorFunction, spy } = params
const paymentDetails = creatorFunction(defaultParams)
const sendingWalletDescriptor = {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const lastCall = spy.mock.lastCall && spy.mock.lastCall[0]
expect(lastCall).toEqual({ ...defaultParams, sendingWalletDescriptor })
}

export const createGetFeeMocks = (): GetFeeParams => {
return {
lnInvoiceFeeProbe: jest.fn(),
Expand Down
52 changes: 25 additions & 27 deletions __tests__/payment-details/intraledger-payment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import {
expectCannotGetFee,
expectCannotSendPayment,
expectDestinationSpecifiedMemoCannotSetMemo,
getTestSetAmount,
getTestSetMemo,
getTestSetSendingWalletDescriptor,
testAmount,
usdSendingWalletDescriptor,
zeroAmount,
Expand All @@ -25,15 +22,9 @@ const defaultParams: PaymentDetails.CreateIntraledgerPaymentDetailsParams<Wallet
unitOfAccountAmount: testAmount,
}

const spy = jest.spyOn(PaymentDetails, "createIntraledgerPaymentDetails")

describe("intraledger payment details", () => {
const { createIntraledgerPaymentDetails } = PaymentDetails

beforeEach(() => {
spy.mockClear()
})

it("properly sets fields with all arguments provided", () => {
const paymentDetails = createIntraledgerPaymentDetails(defaultParams)
expect(paymentDetails).toEqual(
Expand Down Expand Up @@ -150,29 +141,36 @@ describe("intraledger payment details", () => {
})

it("can set memo if no memo provided", () => {
const testSetMemo = getTestSetMemo()
testSetMemo({
defaultParams,
spy,
creatorFunction: createIntraledgerPaymentDetails,
})
const paymentDetails = createIntraledgerPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})

it("can set amount", () => {
const testSetAmount = getTestSetAmount()
testSetAmount({
defaultParams,
spy,
creatorFunction: createIntraledgerPaymentDetails,
})
const paymentDetails = createIntraledgerPaymentDetails(defaultParams)
const unitOfAccountAmount = {
amount: 100,
currency: WalletCurrency.Btc,
currencyCode: "BTC",
}
if (!paymentDetails.canSetAmount) throw new Error("Amount is unable to be set")
const newPaymentDetails = paymentDetails.setAmount(unitOfAccountAmount)

expect(newPaymentDetails.unitOfAccountAmount).toEqual(unitOfAccountAmount)
})

it("can set sending wallet descriptor", () => {
const testSetSendingWalletDescriptor = getTestSetSendingWalletDescriptor()
testSetSendingWalletDescriptor({
defaultParams,
spy,
creatorFunction: createIntraledgerPaymentDetails,
})
const paymentDetails = createIntraledgerPaymentDetails(defaultParams)
const sendingWalletDescriptor = {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
39 changes: 19 additions & 20 deletions __tests__/payment-details/lnurl-payment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
convertMoneyAmountMock,
createGetFeeMocks,
createSendPaymentMocks,
getTestSetAmount,
getTestSetSendingWalletDescriptor,
testAmount,
usdSendingWalletDescriptor,
} from "./helpers"
Expand Down Expand Up @@ -54,15 +52,9 @@ const defaultParamsWithEqualMinMaxAmount = {
lnurlParams: mockLnUrlPayServiceResponse(100 as Satoshis, 100 as Satoshis),
}

const spy = jest.spyOn(PaymentDetails, "createLnurlPaymentDetails")

describe("lnurl payment details", () => {
const { createLnurlPaymentDetails } = PaymentDetails

beforeEach(() => {
spy.mockClear()
})

it("properly sets fields if min and max amount is equal", () => {
const paymentDetails = createLnurlPaymentDetails(defaultParamsWithEqualMinMaxAmount)
expect(paymentDetails).toEqual(
Expand Down Expand Up @@ -229,20 +221,27 @@ describe("lnurl payment details", () => {
})

it("can set amount", () => {
const testSetAmount = getTestSetAmount()
testSetAmount({
defaultParams: defaultParamsWithoutInvoice,
spy,
creatorFunction: createLnurlPaymentDetails,
})
const paymentDetails = createLnurlPaymentDetails(defaultParamsWithoutInvoice)
const unitOfAccountAmount = {
amount: 100,
currency: WalletCurrency.Btc,
currencyCode: "BTC",
}
if (!paymentDetails.canSetAmount) throw new Error("Amount is unable to be set")
const newPaymentDetails = paymentDetails.setAmount(unitOfAccountAmount)

expect(newPaymentDetails.unitOfAccountAmount).toEqual(unitOfAccountAmount)
})

it("can set sending wallet descriptor", () => {
const testSetSendingWalletDescriptor = getTestSetSendingWalletDescriptor()
testSetSendingWalletDescriptor({
defaultParams: defaultParamsWithoutInvoice,
spy,
creatorFunction: createLnurlPaymentDetails,
})
const paymentDetails = createLnurlPaymentDetails(defaultParamsWithoutInvoice)
const sendingWalletDescriptor = {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
Loading
Loading