Skip to content

Commit

Permalink
fix: broken tests after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Mar 27, 2024
1 parent 39cae7a commit 1854f0a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/controllers/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type StateKey = keyof AccountControllerState
const state = proxy<AccountControllerState>({
isConnected: false,
currentTab: 0,
tokenBalance: []
tokenBalance: [],
smartAccountDeployed: false
})

// -- Controller ---------------------------------------- //
Expand Down Expand Up @@ -108,5 +109,6 @@ export const AccountController = {
state.profileName = undefined
state.profileImage = undefined
state.addressExplorerUrl = undefined
state.tokenBalance = []
}
}
21 changes: 19 additions & 2 deletions packages/core/tests/controllers/AccountController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const explorerUrl = 'https://some.explorer.com/explore'
// -- Tests --------------------------------------------------------------------
describe('AccountController', () => {
it('should have valid default state', () => {
expect(AccountController.state).toEqual({ isConnected: false })
expect(AccountController.state).toEqual({
isConnected: false,
smartAccountDeployed: false,
currentTab: 0,
tokenBalance: []
})
})

it('should update state correctly on setIsConnected()', () => {
Expand Down Expand Up @@ -54,6 +59,18 @@ describe('AccountController', () => {

it('should update state correctly on resetAccount()', () => {
AccountController.resetAccount()
expect(AccountController.state).toEqual({ isConnected: false, smartAccountDeployed: false })
expect(AccountController.state).toEqual({
isConnected: false,
smartAccountDeployed: false,
currentTab: 0,
caipAddress: undefined,
address: undefined,
balance: undefined,
balanceSymbol: undefined,
profileName: undefined,
profileImage: undefined,
addressExplorerUrl: undefined,
tokenBalance: []
})
})
})
14 changes: 10 additions & 4 deletions packages/core/tests/controllers/ConnectorController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ const emailProvider = {
syncTheme: (_args: { themeMode: ThemeMode; themeVariables: ThemeVariables }) => Promise.resolve()
}

const walletConnectConnector = { id: 'walletConnect', type: 'WALLET_CONNECT' } as const
const walletConnectConnector = {
id: 'walletConnect',
explorerId: 'walletConnect',
type: 'WALLET_CONNECT'
} as const
const externalConnector = { id: 'external', type: 'EXTERNAL' } as const
const emailConnector = { id: 'w3mEmail', type: 'EMAIL', provider: emailProvider } as const
const announcedConnector = {
id: 'metamask',
id: 'announced',
type: 'ANNOUNCED',
info: { rdns: 'metamask.io' }
info: { rdns: 'announced.io' }
} as const

const syncDappDataSpy = vi.spyOn(emailProvider, 'syncDappData')
Expand Down Expand Up @@ -88,6 +92,7 @@ describe('ConnectorController', () => {
expect(ConnectorController.state.connectors).toEqual([
walletConnectConnector,
externalConnector,
metamaskConnector,
emailConnector
])

Expand All @@ -105,13 +110,14 @@ describe('ConnectorController', () => {

it('getAnnouncedConnectorRdns() should return corresponding info array', () => {
ConnectorController.addConnector(announcedConnector)
expect(ConnectorController.getAnnouncedConnectorRdns()).toEqual(['metamask.io'])
expect(ConnectorController.getAnnouncedConnectorRdns()).toEqual(['announced.io'])
})

it('getConnnectors() should return all connectors', () => {
expect(ConnectorController.getConnectors()).toEqual([
walletConnectConnector,
externalConnector,
metamaskConnector,
emailConnector,
announcedConnector
])
Expand Down

0 comments on commit 1854f0a

Please sign in to comment.