improved error handling for invalid content

This commit is contained in:
Philipp Kühn
2018-11-16 14:12:25 +01:00
parent 41a6fd54c5
commit abfc9d5331
3 changed files with 48 additions and 7 deletions

View File

@@ -25,6 +25,38 @@ test('create editor', () => {
expect(editor).toBeDefined()
})
test('check invalid content (JSON)', () => {
const editor = new Editor({
content: { thisIsNotAValidDocument: true },
})
expect(editor.getHTML()).toEqual('<p></p>')
})
test('check invalid content (HTML)', () => {
const editor = new Editor({
content: '</>',
})
expect(editor.getHTML()).toEqual('<p></p>')
})
test('check invalid content (unsupported format: Function)', () => {
const editor = new Editor({
content: () => false,
})
expect(editor.getHTML()).toEqual('<p></p>')
})
test('check invalid content (unsupported format: Array)', () => {
const editor = new Editor({
content: [],
})
expect(editor.getHTML()).toEqual('<p></p>')
})
test('set HTML, get HTML', () => {
const content = '<p>Lorem <strong>ipsum</strong> dolor sit amet.</p>'