This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate getNethash and requestToActivePeer to avoid mock problems in…
… tests
- Loading branch information
Gina Contrino
committed
Oct 13, 2017
1 parent
7e1d9d3
commit c867b29
Showing
5 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { requestToActivePeer } from './peers'; | ||
|
||
/* eslint-disable */ | ||
export const getNethash = activePeer => (requestToActivePeer(activePeer, 'blocks/getNethash')); | ||
/* eslint-enable */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from 'chai'; | ||
import { mock } from 'sinon'; | ||
import * as peers from './peers'; | ||
import { getNethash } from './nethash'; | ||
|
||
|
||
describe('Utils: Nethash', () => { | ||
let peersMock; | ||
const activePeer = {}; | ||
|
||
beforeEach(() => { | ||
peersMock = mock(peers); | ||
}); | ||
|
||
afterEach(() => { | ||
peersMock.restore(); | ||
}); | ||
|
||
it('should return the result from requestToActivePeer call', () => { | ||
const mockedReturns = 'requestToActivePeer returns something'; | ||
|
||
peersMock.expects('requestToActivePeer') | ||
.withArgs(activePeer, 'blocks/getNethash') | ||
.returns(mockedReturns); | ||
|
||
const returnedPromise = getNethash(activePeer); | ||
expect(returnedPromise).to.equal(mockedReturns); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters