Skip to content

Commit

Permalink
Remove eth_testing package from auth-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv committed May 27, 2024
1 parent 357d6b2 commit 6e3ef46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion packages/auth-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"access": "public"
},
"devDependencies": {
"eth-testing": "^1.14.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
22 changes: 13 additions & 9 deletions packages/auth-kit/src/packs/safe-auth/SafeAuthPack.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { SafeAuthPack } from './SafeAuthPack'
import { generateTestingUtils } from 'eth-testing'
import { AuthKitBasePack } from '@safe-global/auth-kit/index'
import { SafeAuthInitOptions } from './types'
import { CHAIN_CONFIG } from './constants'

const testingUtils = generateTestingUtils({ providerType: 'MetaMask' })
const mockProvider = testingUtils.getProvider()
const mockProvider = {
request: async ({ method }: { method: string }) => {
if (method === 'eth_accounts') {
return Promise.resolve(['0xf61B443A155b07D2b2cAeA2d99715dC84E839EEf'])
}

if (method === 'eth_chainId') {
return Promise.resolve('0x1')
}

return null
}
}
const mockInit = jest.fn()
const mockLogin = jest.fn()
const mockLogout = jest.fn()
Expand Down Expand Up @@ -56,7 +66,6 @@ describe('SafeAuthPack', () => {

beforeEach(() => {
jest.clearAllMocks()
testingUtils.clearAllMocks()
mockInit.mockClear()
mockLogin.mockClear()
})
Expand Down Expand Up @@ -92,9 +101,6 @@ describe('SafeAuthPack', () => {

describe('signIn()', () => {
it('should call the login() method', async () => {
testingUtils.mockAccounts(['0xf61B443A155b07D2b2cAeA2d99715dC84E839EEf'])
testingUtils.mockChainId('0x1')

const authKitSignInData = await safeAuthPack.signIn()

expect(mockLogin).toHaveBeenCalled()
Expand All @@ -120,8 +126,6 @@ describe('SafeAuthPack', () => {
})

it('should return the provider after initialization', async () => {
testingUtils.mockAccounts(['0xf61B443A155b07D2b2cAeA2d99715dC84E839EEf'])

await safeAuthPack.init(safeAuthInitOptions)

expect(safeAuthPack.getProvider()).toEqual(mockProvider)
Expand Down

0 comments on commit 6e3ef46

Please sign in to comment.