Browse Source

Update parser tests

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

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

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

Loading…
Cancel
Save