Skip to content

Commit

Permalink
refactor: Use sleep from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Jul 24, 2020
1 parent 4276fdc commit bbbb793
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/components/ModalStack.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import React, { useState } from 'react'
import Modal from 'cozy-ui/transpiled/react/Modal'
import { ViewStackContext } from 'cozy-ui/transpiled/react'

const sleep = duration => new Promise(resolve => setTimeout(resolve, duration))
import sleep from 'utils/sleep'

// Same as in cozy-ui
const useStack = (initialState, options = {}) => {
Expand Down
3 changes: 1 addition & 2 deletions src/ducks/client/checks.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matches from 'lodash/matches'
import { triggerStates } from 'cozy-client/dist/models/trigger'
import { triggersConn } from 'doctypes'

const sleep = delay => new Promise(resolve => setTimeout(resolve, delay))
import sleep from 'utils/sleep'

const policies = {
'never-executed': triggerState =>
Expand Down
3 changes: 1 addition & 2 deletions src/ducks/client/checks.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import StartupChecksPlugin from './checks'
import CozyClient from 'cozy-client'
import merge from 'lodash/merge'

const sleep = delay => new Promise(resolve => setTimeout(resolve, delay))
import sleep from 'utils/sleep'

describe('startup checks', () => {
beforeEach(() => {
Expand Down
5 changes: 1 addition & 4 deletions src/utils/effects.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const sleep = duration =>
new Promise(resolve => {
setTimeout(resolve, duration)
})
import sleep from 'utils/sleep'

const shakeClassName = 'u-shake'

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/alerts/alerts.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from 'ducks/client/utils'
import { runService, makeToken } from 'test/e2e/utils'
import assert from '../../../src/utils/assert'
import sleep from 'utils/sleep'

const SOFTWARE_ID = 'banks.alerts-e2e'

Expand Down Expand Up @@ -63,8 +64,6 @@ const checkPushForScenario = async (pushServer, scenario) => {
}
}

const sleep = duration => new Promise(resolve => setTimeout(resolve, duration))

const runScenario = async (client, scenario, options) => {
assert(client, 'No client')
await importACHData(client, scenario.data)
Expand Down

0 comments on commit bbbb793

Please sign in to comment.