Skip to content

Commit

Permalink
fix: default imports for parcel bundler (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Addminus authored Mar 21, 2024
1 parent 2b1b516 commit 92f96c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/LiFi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
getTokenApproval,
revokeTokenApproval,
} from './allowance'
import * as balance from './balance'
import balance from './balance'
import { getRpcProvider } from './connectors'
import { RouteExecutionManager } from './execution/RouteExecutionManager'
import { checkPackageUpdates } from './helpers'
Expand All @@ -54,7 +54,6 @@ export class LiFi extends RouteExecutionManager {

constructor(configUpdate: ConfigUpdate) {
super(configUpdate)

this.chainsService = ChainsService.getInstance()

this.chainsService.getChains().then((chains) => {
Expand Down
17 changes: 11 additions & 6 deletions src/LiFi.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import { ChainId, CoinKey, Token, findDefaultToken } from '@lifi/types'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { buildStepObject } from '../test/fixtures'
import { LiFi } from './LiFi'
import * as balance from './balance'
import balance from './balance'
import { convertQuoteToRoute } from './helpers'

vi.mock('./balance', () => ({
getTokenBalancesForChains: vi.fn(() => Promise.resolve([])),
getTokenBalance: vi.fn(() => Promise.resolve([])),
getTokenBalances: vi.fn(() => Promise.resolve([])),
}))
vi.mock('./balance', async () => {
const actual = await vi.importActual<typeof import('./balance')>('./balance')
return {
...actual,
getTokenBalancesForChains: vi.fn(() => Promise.resolve([])),
getTokenBalance: vi.fn(() => Promise.resolve([])),
getTokenBalances: vi.fn(() => Promise.resolve([])),
checkBalance: vi.fn(() => Promise.resolve([])),
}
})

const mockedGetTokenBalance = vi.spyOn(balance, 'getTokenBalance')
const mockedGetTokenBalances = vi.spyOn(balance, 'getTokenBalances')
Expand Down

0 comments on commit 92f96c8

Please sign in to comment.