substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).
39 lines (36 loc) • 970 B
JavaScript
import { test } from 'substance-test'
import { CustomSelection } from 'substance'
test('CustomSelection: Creating a CustomSelection', t => {
t.doesNotThrow(() => {
new CustomSelection({ // eslint-disable-line no-new
customType: 'test',
data: { bar: 'baz' },
nodeId: 'foo'
})
})
t.throws(() => {
new CustomSelection({ // eslint-disable-line no-new
nodeId: 'foo'
})
}, /customType/, 'should throw if customType not given')
t.throws(() => {
new CustomSelection({ // eslint-disable-line no-new
customType: 'test'
})
}, /nodeId/, 'should throw if nodeId not given')
t.end()
})
test('CustomSelection: toJSON()', t => {
const sel = new CustomSelection({
customType: 'test',
data: { bar: 'baz' },
nodeId: 'foo'
})
t.deepEqual(sel.toJSON(), {
type: 'custom',
customType: 'test',
data: { bar: 'baz' },
nodeId: 'foo'
}, 'toJSON() should provide correct result')
t.end()
})