Skip to content

Commit

Permalink
Fixup! Rename sinonFakeTimer -> testTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 1, 2021
1 parent e268019 commit 102e5aa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/shortcuts/__tests__/undo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import undoShortcut from '../undo'
import { initialState } from '../../util'
import * as undoUtils from '../../util/isUndoEnabled'
import { setCursorFirstMatchActionCreator } from '../../test-helpers/setCursorFirstMatch'
import sinonFakeTimer from '../../test-helpers/sinonFakeTimer'
import testTimer from '../../test-helpers/testTimer'
import { initialize } from '../../initialize'

const fakeTimer = sinonFakeTimer()
const timer = testTimer()

describe('undo shortcut', () => {
const isUndoEnabled = jest.spyOn(undoUtils, 'isUndoEnabled')
Expand Down Expand Up @@ -77,12 +77,12 @@ it('undo thought change', () => {
it('persists undo thought change', async () => {

/**
* Note: we can't use await with initialize as that results in a timeout error due to dexie. It's handled using the useFakeTimer from Sinon.
* Note: we can't use await with initialize as that results in a timeout error due to dexie. It's handled using the usetestTimer from Sinon.
* More on that here - https://github.com/cybersemics/em/issues/919#issuecomment-739135971.
*/
initialize()

fakeTimer.useFakeTimer()
timer.usetimer()

appStore.dispatch([
importText({
Expand All @@ -95,15 +95,15 @@ it('persists undo thought change', async () => {
newThought({ value: 'alpha', insertNewSubthought: true }), { type: 'undoAction' }
]
)
await fakeTimer.runAllAsync()
await timer.runAllAsync()

fakeTimer.useRealTimer()
timer.useRealTimer()

// clear and call initialize again to reload from local db (simulating page refresh)
appStore.dispatch(clear())
fakeTimer.useFakeTimer()
timer.usetimer()
initialize()
await fakeTimer.runAllAsync()
await timer.runAllAsync()

const exported = exportContext(appStore.getState(), [ROOT_TOKEN], 'text/plain')

Expand Down

0 comments on commit 102e5aa

Please sign in to comment.