Skip to content

Commit

Permalink
tests/containers/entropy: fix issue because of SKIP_ENTROPY_COLLECTION
Browse files Browse the repository at this point in the history
  • Loading branch information
mnzaki committed Aug 20, 2019
1 parent 9448d62 commit 92ee5ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const isDev = env === 'development'
const isTest = env === 'test'
const isTestE2E = env === 'test-e2e'

export const SKIP_ENTROPY_COLLECTION = isDev || isTest || isTestE2E
export const SKIP_ENTROPY_COLLECTION = isDev || isTestE2E
export const SKIP_IDENTITY_REGISTRATION = isDev || isTestE2E
15 changes: 11 additions & 4 deletions tests/ui/containers/entropy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ import { stub, reveal } from 'tests/utils'
describe('Entropy container', () => {
const mockInstanceGenerator = (
instance: EntropyContainer,
progressValues = [0],
progressValues: number[] | null = null,
) => {
const getProgress = jest.fn().mockReturnValue(progressValues[0])
const getProgress = jest.fn()
// @ts-ignore private
const generatorMock = (instance.entropyGenerator = stub<EntropyGenerator>({
getProgress,
addFromDelta: jest.fn(),
generateRandomString: jest.fn().mockReturnValue('randomString'),
}))

progressValues.forEach(v => getProgress.mockReturnValueOnce(v))
if (progressValues) {
getProgress.mockReturnValue(progressValues[0])
progressValues.forEach(v => getProgress.mockReturnValueOnce(v))
} else {
getProgress.mockImplementation(() => {
throw new Error("shouldn't get here!")
})
}

return generatorMock
}
Expand All @@ -45,7 +52,7 @@ describe('Entropy container', () => {
it('correctly handles added points with the entropy generator', () => {
const rendered = shallow(<EntropyContainer {...props} />)
const instance = rendered.instance() as EntropyContainer
const generatorMock = mockInstanceGenerator(instance)
const generatorMock = mockInstanceGenerator(instance, [0])

expect(rendered.state()).toMatchSnapshot()

Expand Down

0 comments on commit 92ee5ca

Please sign in to comment.