From 92ee5ca56fac746ea89e79cd294520374e783014 Mon Sep 17 00:00:00 2001 From: Mina Nagy Zaki Date: Tue, 20 Aug 2019 16:35:11 +0200 Subject: [PATCH] tests/containers/entropy: fix issue because of SKIP_ENTROPY_COLLECTION --- src/env.ts | 2 +- tests/ui/containers/entropy.test.tsx | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/env.ts b/src/env.ts index 4b0b40445a..f667401dca 100644 --- a/src/env.ts +++ b/src/env.ts @@ -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 diff --git a/tests/ui/containers/entropy.test.tsx b/tests/ui/containers/entropy.test.tsx index 5c480cf10c..c57e72c930 100644 --- a/tests/ui/containers/entropy.test.tsx +++ b/tests/ui/containers/entropy.test.tsx @@ -8,9 +8,9 @@ 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({ getProgress, @@ -18,7 +18,14 @@ describe('Entropy container', () => { 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 } @@ -45,7 +52,7 @@ describe('Entropy container', () => { it('correctly handles added points with the entropy generator', () => { const rendered = shallow() const instance = rendered.instance() as EntropyContainer - const generatorMock = mockInstanceGenerator(instance) + const generatorMock = mockInstanceGenerator(instance, [0]) expect(rendered.state()).toMatchSnapshot()