Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #114 from blockchain/pairing
Browse files Browse the repository at this point in the history
test(Pairing): add tests for making a pairing code
  • Loading branch information
Sjors committed Feb 9, 2016
2 parents 2c41a48 + 04896a4 commit ef8794a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/wallet_spec.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ describe "Wallet", ->

beforeEach ->


describe "makePairingCode()", ->
success = undefined
error = undefined

beforeEach ->
MyWallet.wallet =
guid: 'wallet-guid'
sharedKey: 'shared-key'
spyOn(MyWallet, 'securePost').and.callFake((_a, _b, cb) -> cb('enc-phrase'))
spyOn(WalletStore, 'getPassword').and.returnValue('pw')
spyOn(WalletCrypto, 'encrypt').and.callFake((d) -> "(enc:#{d})")
success = jasmine.createSpy('pairing code success')
error = jasmine.createSpy('pairing code error')

it "should make a pairing code", ->
MyWallet.makePairingCode(success, error)
expect(success).toHaveBeenCalledWith('1|wallet-guid|(enc:shared-key|7077)')
expect(error).not.toHaveBeenCalled()

it "should call WalletCrypto.encrypt with the encryption phrase", ->
MyWallet.makePairingCode(success, error)
expect(WalletCrypto.encrypt).toHaveBeenCalledWith('shared-key|7077', 'enc-phrase', 10)
expect(error).not.toHaveBeenCalled()

describe "stretchPassword()", ->
it "should stretch a password", ->
password = "1234567890"
Expand Down

0 comments on commit ef8794a

Please sign in to comment.