From abc75027cab6cd21fccd7f5503c2ba97193f76c6 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 4 Jun 2021 08:11:09 +0200 Subject: [PATCH] Update symbols tests --- test/specs/dom_components/model/Symbols.js | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/specs/dom_components/model/Symbols.js b/test/specs/dom_components/model/Symbols.js index 5c06bd5a4..d8ccbb2f5 100644 --- a/test/specs/dom_components/model/Symbols.js +++ b/test/specs/dom_components/model/Symbols.js @@ -31,6 +31,13 @@ describe('Symbols', () => { let allInst, all, comp, symbol, compInitChild; let secComp, secSymbol; + const toHTML = cmp => + cmp.toHTML({ + attributes: (m, attr) => { + delete attr.id; + return attr; + } + }); const getUm = cmp => cmp.em.get('UndoManager'); const getInnerComp = (cmp, i = 0) => cmp.components().at(i); const getFirstInnSymbol = cmp => getInnerComp(cmp).__getSymbol(); @@ -42,14 +49,8 @@ describe('Symbols', () => { cFrom.components(`New text content ${rand}`); const toAttr = cTo.getAttributes(); delete toAttr.id; - const htmlOpts = { - attributes: (m, attr) => { - delete attr.id; - return attr; - } - }; expect(toAttr).toEqual(newAttr); - expect(cFrom.toHTML(htmlOpts)).toBe(cTo.toHTML(htmlOpts)); + expect(toHTML(cFrom)).toBe(toHTML(cTo)); }; beforeAll(() => { @@ -89,7 +90,7 @@ describe('Symbols', () => { expect(comp.__getSymbol()).toBe(symbol); expect(symbs.length).toBe(1); expect(symbs[0]).toBe(comp); - expect(comp.toHTML()).toBe(symbol.toHTML()); + expect(toHTML(comp)).toBe(toHTML(symbol)); }); test('Create 1 symbol and clone the instance for another one', () => { @@ -101,7 +102,7 @@ describe('Symbols', () => { expect(symbs[0]).toBe(comp); expect(symbs[1]).toBe(comp2); expect(comp2.__getSymbol()).toBe(symbol); - expect(comp2.toHTML()).toBe(symbol.toHTML()); + expect(toHTML(comp2)).toBe(toHTML(symbol)); }); test('Create 1 symbol and clone it to have another instance', () => { @@ -113,7 +114,7 @@ describe('Symbols', () => { expect(symbs[0]).toBe(comp); expect(symbs[1]).toBe(comp2); expect(comp2.__getSymbol()).toBe(symbol); - expect(comp2.toHTML()).toBe(symbol.toHTML()); + expect(toHTML(comp2)).toBe(toHTML(symbol)); }); test('Symbols and instances are correctly serialized', () => { @@ -354,8 +355,8 @@ describe('Symbols', () => { expect(attrs[attrKey2]).toBe(attrValue2); }); // All symbols still have the same HTML - const symbHtml = symbol.toHTML(); - all.forEach(cmp => expect(cmp.toHTML()).toBe(symbHtml)); + const symbHtml = toHTML(symbol); + all.forEach(cmp => expect(toHTML(cmp)).toBe(symbHtml)); }); test('Cloning a component in an instance, reflects changes to all symbols', () => { @@ -468,7 +469,7 @@ describe('Symbols', () => { symbol.components('Test text'); // The symbol has changed, but istances should remain the same expect(symbol.components().length).toBe(1); - allInst.forEach(cmp => expect(cmp.toHTML()).toBe(comp.toHTML())); + allInst.forEach(cmp => expect(toHTML(cmp)).toBe(toHTML(comp))); allInst.forEach(cmp => expect(cmp.components().length).toBe(innCompsLen) ); @@ -564,7 +565,7 @@ describe('Symbols', () => { expect(secComp.__getSymbol()).toBe(secSymbol); expect(symbs.length).toBe(1); expect(symbs[0]).toBe(secComp); - expect(secComp.toHTML()).toBe(secSymbol.toHTML()); + expect(toHTML(secComp)).toBe(toHTML(secSymbol)); }); test('Adding the instance, of the second symbol, inside the first symbol, propagates correctly to all first instances', () => {