Browse Source

Update parser tests

pull/3167/head
Artur Arseniev 6 years ago
parent
commit
a6cc38fb9a
  1. 14
      test/specs/editor/index.js
  2. 32
      test/specs/parser/model/ParserHtml.js

14
test/specs/editor/index.js

@ -48,8 +48,8 @@ describe('Editor', () => {
test('Components are correctly tracked on add', () => { test('Components are correctly tracked on add', () => {
const all = editor.Components.allById(); const all = editor.Components.allById();
const wrapper = editor.getWrapper(); const wrapper = editor.getWrapper();
wrapper.append('<div>Component</div>'); wrapper.append('<div>Component</div>'); // Div component + textnode
expect(keys(all).length).toBe(1 + initComps); expect(keys(all).length).toBe(2 + initComps);
}); });
test('Components are correctly tracked on add and remove', () => { test('Components are correctly tracked on add and remove', () => {
@ -59,13 +59,13 @@ describe('Editor', () => {
<div>Component 1</div> <div>Component 1</div>
<div></div> <div></div>
`); `);
expect(keys(all).length).toBe(2 + initComps); expect(keys(all).length).toBe(3 + initComps);
const secComp = added[1]; const secComp = added[1];
secComp.append(` secComp.append(`
<div>Component 2</div> <div>Component 2</div>
<div>Component 3</div> <div>Component 3</div>
`); `);
expect(keys(all).length).toBe(4 + initComps); expect(keys(all).length).toBe(7 + initComps);
wrapper.empty(); wrapper.empty();
expect(wrapper.components().length).toBe(0); expect(wrapper.components().length).toBe(0);
expect(keys(all).length).toBe(initComps); expect(keys(all).length).toBe(initComps);
@ -84,7 +84,7 @@ describe('Editor', () => {
expect(umStack.length).toBe(2); expect(umStack.length).toBe(2);
expect(keys(all).length).toBe(initComps); expect(keys(all).length).toBe(initComps);
um.undo(false); um.undo(false);
expect(keys(all).length).toBe(1 + initComps); expect(keys(all).length).toBe(2 + initComps);
}); });
test('Components are correctly tracked with UndoManager and mutiple operations', () => { test('Components are correctly tracked with UndoManager and mutiple operations', () => {
@ -99,7 +99,7 @@ describe('Editor', () => {
<div>Component 2</div> <div>Component 2</div>
</div>`); </div>`);
expect(umStack.length).toBe(1); // UM counts first children expect(umStack.length).toBe(1); // UM counts first children
expect(keys(all).length).toBe(3 + initComps); expect(keys(all).length).toBe(5 + initComps);
wrapper wrapper
.components() .components()
.at(0) .at(0)
@ -109,7 +109,7 @@ describe('Editor', () => {
// UM registers 2 identical remove undoTypes as Backbone triggers remove from the // UM registers 2 identical remove undoTypes as Backbone triggers remove from the
// collection and the model // collection and the model
expect(umStack.length).toBe(3); expect(umStack.length).toBe(3);
expect(keys(all).length).toBe(2 + initComps); expect(keys(all).length).toBe(3 + initComps);
wrapper.empty(); wrapper.empty();
expect(umStack.length).toBe(4); expect(umStack.length).toBe(4);
expect(keys(all).length).toBe(initComps); expect(keys(all).length).toBe(initComps);

32
test/specs/parser/model/ParserHtml.js

@ -130,7 +130,7 @@ describe('ParserHtml', () => {
tagName: 'div', tagName: 'div',
attributes: { id: 'test1' }, attributes: { id: 'test1' },
type: 'text', type: 'text',
content: 'test2 ' components: 'test2 '
} }
]; ];
expect(obj.parse(str).html).toEqual(result); expect(obj.parse(str).html).toEqual(result);
@ -158,7 +158,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'b', components: 'b',
type: 'text', type: 'text',
tagName: 'b' tagName: 'b'
}, },
@ -168,7 +168,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'i', components: 'i',
tagName: 'i', tagName: 'i',
type: 'text' type: 'text'
}, },
@ -178,7 +178,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'u', components: 'u',
tagName: 'u', tagName: 'u',
type: 'text' type: 'text'
}, },
@ -208,7 +208,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'b', components: 'b',
tagName: 'b', tagName: 'b',
type: 'text' type: 'text'
}, },
@ -218,7 +218,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'i', components: 'i',
tagName: 'i', tagName: 'i',
type: 'text' type: 'text'
}, },
@ -230,7 +230,7 @@ describe('ParserHtml', () => {
{ {
tagName: 'div', tagName: 'div',
type: 'text', type: 'text',
content: 'ABC' components: 'ABC'
}, },
{ {
content: ' ', content: ' ',
@ -238,7 +238,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'i', components: 'i',
tagName: 'i', tagName: 'i',
type: 'text' type: 'text'
}, },
@ -248,7 +248,7 @@ describe('ParserHtml', () => {
tagName: '' tagName: ''
}, },
{ {
content: 'u', components: 'u',
tagName: 'u', tagName: 'u',
type: 'text' type: 'text'
}, },
@ -313,7 +313,7 @@ describe('ParserHtml', () => {
{ {
tagName: 'div', tagName: 'div',
type: 'text', type: 'text',
content: 'nested' components: 'nested'
}, },
{ {
tagName: '', tagName: '',
@ -343,7 +343,7 @@ describe('ParserHtml', () => {
{ {
tagName: 'span', tagName: 'span',
type: 'text', type: 'text',
content: 'nested' components: 'nested'
} }
] ]
}, },
@ -448,7 +448,7 @@ describe('ParserHtml', () => {
}, },
{ {
tagName: 'p', tagName: 'p',
content: 'TestText', components: 'TestText',
type: 'text' type: 'text'
}, },
{ {
@ -475,7 +475,7 @@ describe('ParserHtml', () => {
'data-test': 'test-value' 'data-test': 'test-value'
}, },
type: 'text', type: 'text',
content: 'test2 ' components: 'test2 '
} }
]; ];
expect(obj.parse(str).html).toEqual(result); expect(obj.parse(str).html).toEqual(result);
@ -494,7 +494,7 @@ describe('ParserHtml', () => {
'data-test': 'test-value' 'data-test': 'test-value'
}, },
type: 'text', type: 'text',
content: 'test2 ' components: 'test2 '
} }
]; ];
expect(obj.parse(str).html).toEqual(result); expect(obj.parse(str).html).toEqual(result);
@ -512,7 +512,7 @@ describe('ParserHtml', () => {
prop2: 10, prop2: 10,
prop3: true prop3: true
}, },
content: 'test2 ' components: 'test2 '
} }
]; ];
expect(obj.parse(str).html).toEqual(result); expect(obj.parse(str).html).toEqual(result);
@ -526,7 +526,7 @@ describe('ParserHtml', () => {
attributes: {}, attributes: {},
type: 'text', type: 'text',
test: ['value1', 'value2'], test: ['value1', 'value2'],
content: 'test2 ' components: 'test2 '
} }
]; ];
expect(obj.parse(str).html).toEqual(result); expect(obj.parse(str).html).toEqual(result);

Loading…
Cancel
Save