Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
- run unit tests under proper NODE_ENV
- fix fuelKeyWithEther call/test
- minor typescript issues
  • Loading branch information
mnzaki committed Aug 16, 2019
1 parent 05eba0d commit c6fe7d6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
},
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
"test": "NODE_ENV=test jest",
"test:debug": "NODE_ENV=test node --inspect-brk node_modules/.bin/jest --runInBand",
"run:ios": "react-native run-ios",
"run:android": "react-native run-android --appIdSuffix debug",
"run:android:staging": "react-native run-android --variant staging --appIdSuffix debugStaging",
Expand Down
6 changes: 4 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ const typeOrmConf: ConnectionOptions = {

const env = process.env['NODE_ENV'] || 'development'
const isDev = env === 'development'
// @ts-ignore
const isTest = env === 'test'
const isTestE2E = env === 'test-e2e'

export const skipEntropyCollection = isDev || isTest
export const skipIdentityRegisteration = isDev || isTest
export const skipEntropyCollection = isDev || isTest || isTestE2E
export const skipIdentityRegisteration = isDev || isTestE2E

export default {
fuelingEndpoint: 'https://faucet.jolocom.com/request',
Expand Down
1 change: 0 additions & 1 deletion src/lib/storage/entities/verifiableCredentialEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import {
Exclude,
Expose,
Transform,
plainToClass,
classToPlain,
} from 'class-transformer'
Expand Down
6 changes: 2 additions & 4 deletions src/ui/registration/containers/entropy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ export class EntropyContainer extends React.Component<Props, State> {
}

private updateEntropyProgress = async (): Promise<void> => {
let { entropyProgress } = this.state
if (skipEntropyCollection) {
entropyProgress = 1
}
const entropyProgress = skipEntropyCollection ? 1 : this.state.entropyProgress

if (entropyProgress >= 1) {
this.setState({ sufficientEntropy: true, entropyProgress: 1 })
while (this.entropyGenerator.getProgress() < 1) {
Expand Down
7 changes: 2 additions & 5 deletions tests/actions/registration/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { registrationActions } from 'src/actions'
import data from './data/mockRegistrationData'
import { JolocomLib } from 'jolocom-lib'
import * as util from 'src/lib/util'
import { withErrorScreen } from 'src/actions/modifiers'
import { AppError, ErrorCode } from 'src/lib/errors'
Expand Down Expand Up @@ -79,9 +78,6 @@ describe('Registration action creators', () => {
it('should attempt to create an identity', async () => {
MockDate.set(new Date(946681200000))
const { getPasswordResult, cipher, entropy, identityWallet } = data
const fuelSpy = jest
.spyOn(JolocomLib.util, 'fuelKeyWithEther')
.mockResolvedValueOnce(null)

const mockMiddleware = {
identityWallet,
Expand All @@ -107,6 +103,7 @@ describe('Registration action creators', () => {
create: () => identityWallet,
},
setIdentityWallet: jest.fn(() => Promise.resolve()),
fuelKeyWithEther: jest.fn().mockResolvedValueOnce(null)
}

const mockState: Partial<RootState> = {
Expand Down Expand Up @@ -134,7 +131,7 @@ describe('Registration action creators', () => {
expect(
mockMiddleware.storageLib.store.derivedKey.mock.calls,
).toMatchSnapshot()
expect(fuelSpy.mock.calls).toMatchSnapshot()
expect(mockMiddleware.fuelKeyWithEther.mock.calls).toMatchSnapshot()
MockDate.reset()
})

Expand Down

0 comments on commit c6fe7d6

Please sign in to comment.