Skip to content

Commit

Permalink
test(portable-text-editor): move constant to allow testing without bu…
Browse files Browse the repository at this point in the history
…ilding
  • Loading branch information
mariuslundgard committed Sep 28, 2022
1 parent 3ea485a commit b5590e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/@sanity/portable-text-editor/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Debounce time for flushing local patches (ms since user haven't produced a patch)
* (lower time for tests to speed them up)
*/
export const FLUSH_PATCHES_DEBOUNCE_MS = process.env.NODE_ENV === 'test' ? 50 : 1000
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ import {validateValue} from '../utils/validateValue'
import {debugWithName} from '../utils/debug'
import {getValueOrInitialValue, isEqualToEmptyEditor, toSlateValue} from '../utils/values'
import {KEY_TO_SLATE_ELEMENT, KEY_TO_VALUE_ELEMENT} from '../utils/weakMaps'
import {FLUSH_PATCHES_DEBOUNCE_MS} from '../constants'
import {PortableTextEditorContext} from './hooks/usePortableTextEditor'
import {PortableTextEditorSelectionContext} from './hooks/usePortableTextEditorSelection'
import {PortableTextEditorReadOnlyContext} from './hooks/usePortableTextReadOnly'
import {PortableTextEditorValueContext} from './hooks/usePortableTextEditorValue'
import {withPlugins} from './plugins'

// Debounce time for flushing local patches (ms since user haven't produced a patch)
// (lower time for tests to speed them up)
export const FLUSH_PATCHES_DEBOUNCE_MS = process.env.NODE_ENV === 'test' ? 50 : 1000

export const defaultKeyGenerator = () => randomKey(12)

const debug = debugWithName('component:PortableTextEditor')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import puppeteer, {ElementHandle, KeyInput} from 'puppeteer'
import ipc from 'node-ipc'
import {isEqual} from 'lodash'
import {EditorSelection, PortableTextBlock} from '../../src'
import {FLUSH_PATCHES_DEBOUNCE_MS} from '../../src/constants'
import {normalizeSelection} from '../../src/utils/selection'
import {FLUSH_PATCHES_DEBOUNCE_MS} from '../../src/editor/PortableTextEditor'

ipc.config.id = 'collaborative-jest-environment-ipc-client'
ipc.config.retry = 1500
Expand Down

0 comments on commit b5590e3

Please sign in to comment.