Skip to content

Commit

Permalink
add test for init
Browse files Browse the repository at this point in the history
  • Loading branch information
bergarces committed Nov 17, 2022
1 parent 184b1ea commit 775c1cf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/test-eth-ledger-keyring-mv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ describe('LedgerBridgeKeyring', function () {
})
})

describe('init', function () {
it('should set up the iFrame', function () {
const iframeMock = {}
sandbox.on(global.document, 'createElement', () => iframeMock)
sandbox.on(global.document.head, 'appendChild', () => true)
sandbox.on(global.window, 'addEventListener', () => true)

keyring.init()

expect(global.document.createElement).to.have.been.called()
expect(global.document.createElement)
.to.have.been.called.with('iframe')

expect(global.document.head.appendChild).to.have.been.called()
expect(global.document.head.appendChild)
.to.have.been.called.with(iframeMock)

expect(global.window.addEventListener).to.have.been.called()
expect(global.window.addEventListener)
.to.have.been.called.with('message', keyring._eventListener)
})
})

describe('serialize', function () {
it('serializes an instance', function (done) {
keyring.serialize()
Expand Down

0 comments on commit 775c1cf

Please sign in to comment.