test: dapp-sdk unit tests#1992
Conversation
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
mateuszpiatkowski-da
left a comment
There was a problem hiding this comment.
To be continued 😝
| }, | ||
| environment: 'node', | ||
| include: [], | ||
| // include: [], |
There was a problem hiding this comment.
I guess this is not needed anymore?
| ], | ||
| provider: 'v8', | ||
| reporter: ['text', 'html', 'lcov'], | ||
| thresholds: { |
There was a problem hiding this comment.
You don't want to change the values here?
| request: Mock<Provider<DappRpcTypes>['request']> | ||
| } | ||
|
|
||
| const connectedStatus = (): StatusEvent => ({ |
There was a problem hiding this comment.
does it need to be a function? I can see it only used in one place, so I'm not sure if we even need a const here tbh :D
| description: 'Test extension', | ||
| icon: 'data:image/png;base64,abc', | ||
| }) | ||
| expect(adapter.target).toBe('my-wallet') |
There was a problem hiding this comment.
Since we're testing public props here, shouldn't we ensure that name, type, icon (and possibly target) are properly assigned to?
| const adapter = new ExtensionAdapter() | ||
|
|
||
| expect(adapter.providerId).toBe('browser') | ||
| expect(adapter.getInfo().name).toBe('Browser Extension') |
There was a problem hiding this comment.
I'd add the description property to test as well via getInfo()
| }, | ||
| })) | ||
|
|
||
| const kernelSession = (): StatusEvent => ({ |
There was a problem hiding this comment.
I guess it doesn't necessarily need to be a function if it's just an object which we read (function is ok though)
| }) | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks() |
There was a problem hiding this comment.
Are you sure we need it? We have the clearing of mocks in beforeEach hence the question
| tx: { commandId: 'cmd-1', status: 'executed' }, | ||
| }) | ||
| mockController.signMessage.mockResolvedValue({ signature: 'sig' }) | ||
| mockController.ledgerApi.mockResolvedValue({ ok: true }) |
There was a problem hiding this comment.
if you want we can do sth like this:
| mockController.ledgerApi.mockResolvedValue({ ok: true }) | |
| mockController.ledgerApi.mockResolvedValue({ ok: true }) | |
| adapter = new RemoteAdapter({ | |
| name: 'Gateway', | |
| rpcUrl: RPC_URL | |
| }) |
and just declare the var via let above
this way you can omit the need to create the adapter each time you want to use it.
| 'statusChanged', | ||
| listener | ||
| ) | ||
| expect(mockDappAsyncProvider.emit).toHaveBeenCalledWith( |
There was a problem hiding this comment.
we don't want to check if listener has beed called too? I'm not into the business logic as much so I'm just not sure about it tho :p
| expect(popup.close).toHaveBeenCalled() | ||
| }) | ||
|
|
||
| describe('restore', () => { |
There was a problem hiding this comment.
I'd also add the test when discovery.walletType !== 'remote'
Signed-off-by: Pawel Stepien <pawel.stepien@digitalasset.com>
Note:
dapp-sdk integration tests run together with units on yarn test / test:coverage, but only unit tests count to coverage.