Skip to content

Commit

Permalink
fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Empowerful committed Oct 9, 2019
1 parent d93fba8 commit 1205342
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 325 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@
"ci:compile": "cross-env-shell NODE_ENV=production webpack-cli --config webpack.config.ci.js --display-error-details",
"ci:coverage:components": "yarn workspace blockchain-info-components ci:coverage:components",
"ci:coverage:core": "yarn workspace blockchain-wallet-v4 ci:coverage:core",
"ci:coverage:main-process": "yarn workspace main-process ci:coverage:frontend",
"ci:coverage:security-process": "yarn workspace security-process ci:coverage:frontend",
"ci:coverage:main": "yarn workspace main-process ci:coverage:frontend",
"ci:coverage:security": "yarn workspace security-process ci:coverage:frontend",
"ci:coverage:report": "istanbul report --root ./coverage --dir ./coverage/ lcov && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"ci:lint": "prettier './packages/*/src/**/*.js' --loglevel error --write && eslint './packages/*/src/**/*.js' --fix && stylelint './packages/*/src/**/*.js'",
"ci:test:build": "yarn wsrun test:build --serial",
"ci:test:core:components": "yarn wsrun ci:test --serial --exclude-missing",
"ci:test:main-process": "yarn workspace main-process ci:test:frontend",
"ci:test:security-process": "yarn workspace security-process ci:test:frontend",
"ci:test:main": "yarn workspace main-process ci:test:frontend",
"ci:test:security": "yarn workspace security-process ci:test:frontend",
"clean": "cross-env yarn wsrun clean && rimraf build && rimraf coverage && rimraf dist && rimraf *.log && rimraf node_modules",
"coverage": "cross-env rimraf coverage && yarn wsrun coverage --fast-exit && istanbul report --root ./coverage --dir ./coverage/ text-summary html",
"coverage:components": "yarn workspace blockchain-info-components coverage",
"coverage:core": "yarn workspace blockchain-wallet-v4 coverage",
"coverage:main-process": "yarn workspace main-process coverage",
"coverage:security-process": "yarn workspace security-process coverage",
"coverage:main": "yarn workspace main-process coverage",
"coverage:security": "yarn workspace security-process coverage",
"debug:prod": "cross-env-shell NODE_ENV=production webpack-dev-server --config webpack.debug.js --progress --colors",
"fix": "cross-env yarn prettier && yarn lint:fix && yarn test:components:update && yarn test:frontend:update",
"link:resolved:paths": "yarn wsrun link:resolved:paths --exclude-missing",
Expand All @@ -88,13 +88,13 @@
"lint:css": "stylelint './packages/*/src/**/*.js'",
"lint:fix": "eslint './packages/*/src/**/*.js' --fix",
"lint:main-process": "eslint './packages/main-process/src/**/*.js'",
"lint:security-process": "eslint './packages/security-process/src/**/*.js'",
"lint:security": "eslint './packages/security-process/src/**/*.js'",
"manage:translations": "yarn build:prod && node ./translationRunner.js",
"prettier": "prettier './packages/*/src/**/*.js' --loglevel error --write",
"prettier:components": "prettier './packages/blockchain-info-components/src/**/*.js' --list-different --loglevel error --write",
"prettier:core": "prettier './packages/blockchain-wallet-v4/src/**/*.js' --list-different --loglevel error --write",
"prettier:main-process": "prettier './packages/main-process/src/**/*.js' --list-different --loglevel error --write",
"prettier:security-process": "prettier './packages/security-process/src/**/*.js' --list-different --loglevel error --write",
"prettier:main": "prettier './packages/main-process/src/**/*.js' --list-different --loglevel error --write",
"prettier:security": "prettier './packages/security-process/src/**/*.js' --list-different --loglevel error --write",
"start": "yarn workspace root-process start:dev",
"start:dev": "yarn workspace root-process start:dev",
"start:prod": "yarn workspace root-process start:prod",
Expand All @@ -111,14 +111,14 @@
"test:core": "yarn workspace blockchain-wallet-v4 test",
"test:core:debug": "yarn workspace blockchain-wallet-v4 test:debug",
"test:core:watch": "yarn workspace blockchain-wallet-v4 test:watch",
"test:main-process": "yarn workspace main-process test",
"test:main-process:debug": "yarn workspace main-process test:debug",
"test:main-process:update": "yarn workspace main-process test:update",
"test:main-process:watch": "yarn workspace main-process test:watch",
"test:security-process": "yarn workspace security-process test",
"test:security-process:debug": "yarn workspace security-process test:debug",
"test:security-process:update": "yarn workspace security-process test:update",
"test:security-process:watch": "yarn workspace security-process test:watch",
"test:main": "yarn workspace main-process test",
"test:main:debug": "yarn workspace main-process test:debug",
"test:main:update": "yarn workspace main-process test:update",
"test:main:watch": "yarn workspace main-process test:watch",
"test:security": "yarn workspace security-process test",
"test:security:debug": "yarn workspace security-process test:debug",
"test:security:update": "yarn workspace security-process test:update",
"test:security:watch": "yarn workspace security-process test:watch",
"release": "release-it"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ exports[`ListItemContainer renders correctly 1`] = `
"hideSwapBanner": [Function],
"hideSwapUpgradeModal": [Function],
"hideUpgradeForAirdropModal": [Function],
"registerProtocolHandler": [Function],
"setCulture": [Function],
"setLanguage": [Function],
"setTheme": [Function],
Expand Down Expand Up @@ -171,6 +172,7 @@ exports[`ListItemContainer renders correctly 1`] = `
"deleteLegacyAddress": [Function],
"deleteWrapper": [Function],
"mergeWrapper": [Function],
"newHdAccount": [Function],
"refreshWrapper": [Function],
"setAccountArchived": [Function],
"setAccountLabel": [Function],
Expand Down
187 changes: 0 additions & 187 deletions packages/main-process/src/data/auth/sagas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,193 +334,6 @@ describe('authSagas', () => {
})
})

describe('login routine', () => {
const {
authNabu,
checkDataErrors,
loginRoutineSaga,
logoutRoutine,
saveGoals,
setLogoutEventListener,
startSockets,
transferEthSaga,
upgradeWalletSaga,
upgradeAddressLabelsSaga
} = authSagas({
api,
coreSagas
})
const mobileLogin = true
const firstLogin = false

const saga = testSaga(loginRoutineSaga, {
payload: { mobileLogin, firstLogin }
})

const beforeHdCheck = 'beforeHdCheck'

it('should check if wallet is an hd wallet', () => {
saga
.next()
.select(selectors.core.wallet.isHdWallet)
.save(beforeHdCheck)
})

it('should call upgradeWalletSaga if wallet is not hd', () => {
saga
.next(false)
.call(upgradeWalletSaga)
.restore(beforeHdCheck)
})

it('should fetch root', () => {
saga
.next(true)
.call(coreSagas.kvStore.root.fetchRoot, askSecondPasswordEnhancer)
})

it('should fetch eth metadata', () => {
saga
.next()
.call(coreSagas.kvStore.eth.fetchMetadataEth, askSecondPasswordEnhancer)
})

it('should fetch xlm metadata', () => {
saga
.next()
.call(coreSagas.kvStore.xlm.fetchMetadataXlm, askSecondPasswordEnhancer)
})

it('should fetch bch metadata', () => {
saga.next().call(coreSagas.kvStore.bch.fetchMetadataBch)
})

it('should fetch lockbox metadata', () => {
saga.next().call(coreSagas.kvStore.lockbox.fetchMetadataLockbox)
})

it('should redirect to home route', () => {
saga.next().put(actions.router.push('/home'))
})

it('should fetch settings', () => {
saga.next().call(coreSagas.settings.fetchSettings)
})

it('should fetch xlm ledger details', () => {
saga.next().call(coreSagas.data.xlm.fetchLedgerDetails)
})

it('should fetch xlm accounts', () => {
saga.next().call(coreSagas.data.xlm.fetchData)
})

it('should call auth nabu saga', () => {
saga.next().call(authNabu)
})

it('should call upgrade address labels saga', () => {
saga.next().call(upgradeAddressLabelsSaga)
})

it('should trigger login success action', () => {
saga.next().put(actions.auth.loginSuccess())
})

it('should start logout timer', () => {
saga.next().put(actions.auth.startLogoutTimer())
})

it('should start sockets', () => {
saga.next().call(startSockets)
})

it('should select guid from state', () => {
saga.next().select(selectors.core.wallet.getGuid)
})

it('should cache guid', () => {
const guid = 'guid'
saga.next(guid).put(actions.cache.guidEntered(guid))
})

it('should select current language', () => {
saga.next().select(selectors.preferences.getLanguage)
})

it('should trigger update language action with selected language', () => {
const language = 'en'
saga.next(language).put(actions.modules.settings.updateLanguage(language))
})

it('should init analytics user session', () => {
saga.next().put(actions.analytics.initUserSession())
})

it('should launch transferEth saga', () => {
saga.next().fork(transferEthSaga)
})

it('should save goals', () => {
saga.next().call(saveGoals, false)
})

it('should run goals', () => {
saga.next().put(actions.goals.runGoals())
})

it('should check for data errors', () => {
saga.next().fork(checkDataErrors)
})

it('should start listening for logout event', () => {
saga.next().call(setLogoutEventListener)
})

it('should launch logout routine saga upon logout event', () => {
const stubLogoutEvent = {}
saga.next(stubLogoutEvent).fork(logoutRoutine, stubLogoutEvent)
})

it("should not display success if it's first login", () => {
const firstLogin = true

return expectSaga(loginRoutineSaga, {
payload: { mobileLogin, firstLogin }
})
.provide([
// Every async or value returning yield has to be mocked
// for saga to progress
[select(selectors.core.wallet.isHdWallet), true],
[select(selectors.core.wallet.getGuid), 12],
[fork.fn(transferEthSaga), jest.fn],
[call.fn(setLogoutEventListener), jest.fn],
[fork.fn(logoutRoutine), jest.fn]
])
.not.put(actions.alerts.displaySuccess(C.LOGIN_SUCCESS))
.run()
})

describe('error handling', () => {
it('should log error', () => {
const error = {}
saga
.throw(error)
.put(
actions.logs.logErrorMessage(logLocation, 'loginRoutineSaga', error)
)
})

it('should show wallet error alert', () => {
saga
.next()
.put(actions.alerts.displayError(C.WALLET_LOADING_ERROR))
.next()
.isDone()
})
})
})

describe('register flow', () => {
const { register } = authSagas({
api,
Expand Down
48 changes: 0 additions & 48 deletions packages/security-process/src/data/auth/sagas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,54 +324,6 @@ describe('authSagas', () => {
})
})

describe('login routine', () => {
const { loginRoutineSaga } = authSagas({
api,
coreSagas
})
const saga = testSaga(loginRoutineSaga)

it('should put authenticate action', () => {
saga.next().put(actions.auth.authenticate())
})

it('should select guid from state', () => {
saga.next().select(selectors.core.wallet.getGuid)
})

it('should cache guid', () => {
const guid = 'guid'
saga.next(guid).put(actions.cache.guidEntered(guid))
})

it('should reset auth state', () => {
saga.next().put(actions.auth.setAuthType(0))
})

it('should clear login form', () => {
saga.next().put(actions.form.destroy('login'))
})

describe('error handling', () => {
it('should log error', () => {
const error = {}
saga
.throw(error)
.put(
actions.logs.logErrorMessage(logLocation, 'loginRoutineSaga', error)
)
})

it('should show wallet error alert', () => {
saga
.next()
.put(actions.alerts.displayError(C.WALLET_LOADING_ERROR))
.next()
.isDone()
})
})
})

describe('register flow', () => {
const { register } = authSagas({
api,
Expand Down
Loading

0 comments on commit 1205342

Please sign in to comment.