Skip to content

Commit

Permalink
chorE: add test for multi_chain connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Sep 19, 2024
1 parent ef02313 commit a93cdb9
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions packages/core/tests/controllers/ConnectorController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const announcedConnector = {
name: 'Announced'
} as const

const announcedConnectorSolana = {
id: 'announced',
type: 'ANNOUNCED',
info: { rdns: 'announced.solana.io' },
chain: ConstantsUtil.CHAIN.SOLANA,
name: 'Announced'
} as const

const syncDappDataSpy = vi.spyOn(authProvider, 'syncDappData')
const syncThemeSpy = vi.spyOn(authProvider, 'syncTheme')

Expand Down Expand Up @@ -207,4 +215,56 @@ describe('ConnectorController', () => {
announcedConnector
])
})

it('should merge connectors with the same chain', () => {
const mergedAnnouncedConnector = {
id: 'announced',
imageId: undefined,
imageUrl: undefined,
name: 'Announced',
type: 'MULTI_CHAIN',
chain: 'eip155',
connectors: [announcedConnector, announcedConnectorSolana]
}

const mergedAuthConnector = {
id: 'w3mAuth',
imageId: undefined,
imageUrl: undefined,
name: 'Auth',
type: 'AUTH',
chain: 'eip155',
connectors: [
{
chain: 'eip155',
id: 'w3mAuth',
name: 'Auth',
provider: {
syncDappData: syncDappDataSpy,
syncTheme: syncThemeSpy
},
type: 'AUTH'
},
{
chain: 'solana',
id: 'w3mAuth',
name: 'Auth',
provider: {
syncDappData: syncDappDataSpy,
syncTheme: syncThemeSpy
},
type: 'AUTH'
}
]
}
ConnectorController.addConnector(announcedConnectorSolana)
expect(ConnectorController.getConnectors()).toEqual([
walletConnectConnector,
externalConnector,
metamaskConnector,
zerionConnector,
mergedAuthConnector,
mergedAnnouncedConnector
])
})
})

0 comments on commit a93cdb9

Please sign in to comment.