- `;
- const b = `
+ `);
+
+ const htmlB = getDiffableSemanticHTML(`
@@ -145,11 +133,9 @@ describe('getSemanticDomDiff()', () => {
- `;
- const diff = getSemanticDomDiff(a, b);
+ `);
- expect(diff.message).to.equal('attribute [foo="bar"] has been added');
- expect(diff.path).to.equal('div > div#foo > div > div');
+ expect(htmlA).to.not.equal(htmlB);
});
});
});
@@ -157,184 +143,143 @@ describe('getSemanticDomDiff()', () => {
describe('equality', () => {
describe('simple', () => {
it('element', () => {
- const diff = getSemanticDomDiff('
', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('attribute', () => {
- const diff = getSemanticDomDiff('
', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('text', () => {
- const diff = getSemanticDomDiff('
foo
', '
foo
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
});
describe('complex', () => {
it('large template', () => {
- const diff = getSemanticDomDiff(largeTemplate, largeTemplate);
-
- expect(diff).to.equal(null);
- });
-
- it('self closing tags', () => {
- const diff = getSemanticDomDiff('
', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML(largeTemplate);
+ const htmlB = getDiffableSemanticHTML(largeTemplate);
+ expect(htmlA).to.equal(htmlB);
});
});
describe('ordering', () => {
it('attributes order', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('class order', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
});
describe('whitespace', () => {
it('trailing whitespace in attributes', () => {
- const diff = getSemanticDomDiff('
', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('trailing whitespace in class', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('whitespace between classes', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('whitespace before and after template', () => {
- const diff = getSemanticDomDiff('
', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('whitespace in between nodes', () => {
- const diff = getSemanticDomDiff(
- '
foo
',
- '
foo
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
it('whitespace around text nodes', () => {
- const diff = getSemanticDomDiff('
foo
', '
foo
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
});
describe('tabs', () => {
it('tabs before and after template', () => {
- const diff = getSemanticDomDiff('\t\t
\t', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('\t\t
\t');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('tabs in between nodes', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('tabs around text nodes', () => {
- const diff = getSemanticDomDiff('
foo
', '
\tfoo\t
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
\tfoo\t
');
+ expect(htmlA).to.equal(htmlB);
});
});
describe('newlines', () => {
it('newlines before and after template', () => {
- const diff = getSemanticDomDiff('\n\n
\n', '
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('\n\n
\n');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('newlines in between nodes', () => {
- const diff = getSemanticDomDiff(
- '
',
- '
',
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
');
+ const htmlB = getDiffableSemanticHTML('
');
+ expect(htmlA).to.equal(htmlB);
});
it('newlines around text nodes', () => {
- const diff = getSemanticDomDiff('
foo
', '
\n\n\nfoo\n
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
\n\n\nfoo\n
');
+ expect(htmlA).to.equal(htmlB);
});
});
describe('filtered nodes', () => {
it('comments', () => {
- const diff = getSemanticDomDiff('
foo
', '
foo
');
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
it('styles', () => {
- const diff = getSemanticDomDiff(
+ const htmlA = getDiffableSemanticHTML(
'
foo
',
- '
foo
',
);
-
- expect(diff).to.equal(null);
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
it('script', () => {
- const diff = getSemanticDomDiff(
- '
foo
',
- '
foo
',
- );
-
- expect(diff).to.equal(null);
- });
-
- it('ignored tags', () => {
- const diff = getSemanticDomDiff(
- '
foo
',
- '
bar
',
- { ignoredTags: ['span'] },
- );
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML('
foo
');
+ const htmlB = getDiffableSemanticHTML('
foo
');
+ expect(htmlA).to.equal(htmlB);
});
});
@@ -354,35 +299,10 @@ bar
`;
- const diff = getSemanticDomDiff(a, b);
-
- expect(diff).to.equal(null);
+ const htmlA = getDiffableSemanticHTML(a);
+ const htmlB = getDiffableSemanticHTML(b);
+ expect(htmlA).to.equal(htmlB);
});
});
});
-
- describe('values', () => {
- it('handles strings', () => {
- const diff = getSemanticDomDiff('