oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1// writearea.test.mjs — the empty area's drag holds a stale anchor inside
2// the document (build note 84): a document shortened mid-drag, by a
3// teammate's merge, must not throw.
4import { test } from 'node:test'
5import assert from 'node:assert/strict'
6import { EditorState } from 'prosemirror-state'
7import { createSchema } from './schema.mjs'
8import { mount } from './fidelity.mjs'
9import { select } from './writearea.mjs'
10
11function viewOf (body) {
12 const schema = createSchema(() => null)
13 const view = {
14 state: EditorState.create({ doc: mount(schema, body).doc }),
15 dispatch: tr => { view.state = view.state.apply(tr) }
16 }
17 return view
18}
19
20test('a drag whose anchor the document no longer reaches selects to its end', () => {
21 const view = viewOf('Short now.')
22 const size = view.state.doc.content.size
23 assert.doesNotThrow(() => select(view, size + 40, 3))
24 assert.equal(view.state.selection.from, 3)
25 assert.equal(view.state.selection.to, size - 1)
26 assert.doesNotThrow(() => select(view, -5, size + 9))
27})
28