unexpected-htmllike
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -30,2 +30,7 @@ | ||
### v0.5.0 | ||
* Improved output for moved elements in children - provides a hint as to the current index | ||
* Fix for moved elements when actual and expected adapters are different (bruderstein/unexpected-react#9) | ||
(thanks to @yormi for an excellent bug report!) | ||
@@ -101,3 +101,3 @@ // This code originally taken from array-changes https://github.com/unexpectedjs/array-changes | ||
type: 'insert', | ||
value: diffItem.values[i] | ||
value: diffItem.vlues[i] | ||
}; | ||
@@ -104,0 +104,0 @@ } |
@@ -538,3 +538,9 @@ 'use strict'; | ||
insertCount++; | ||
itemResult = (0, _convertToDiff2['default'])(expectedAdapter, diffItem.value); | ||
var actualIndex = null; | ||
if (typeof diffItem.actualIndex === 'number') { | ||
itemResult = (0, _convertToDiff2['default'])(actualAdapter, diffItem.value); | ||
actualIndex = diffItem.actualIndex; | ||
} else { | ||
itemResult = (0, _convertToDiff2['default'])(expectedAdapter, diffItem.value); | ||
} | ||
if (options.diffMissingChildren) { | ||
@@ -545,2 +551,7 @@ diffWeights.add(options.weights.CHILD_MISSING); | ||
}; | ||
if (actualIndex !== null) { | ||
itemResult.diff.actualIndex = actualIndex; | ||
} | ||
diffResult.push(itemResult); | ||
@@ -547,0 +558,0 @@ } |
@@ -29,2 +29,5 @@ 'use strict'; | ||
this.error('missing').sp(); | ||
if (typeof description.diff.actualIndex === 'number') { | ||
this.error('(found at index ' + description.diff.actualIndex + ')').sp(); | ||
} | ||
this.block(function () { | ||
@@ -31,0 +34,0 @@ painter(this, { |
@@ -17,20 +17,8 @@ 'use strict'; | ||
var _mockEntities = require('./mockEntities'); | ||
var expect = _unexpected2['default'].clone(); | ||
var TestAdapter = { | ||
getName: function getName(comp) { | ||
return comp.name; | ||
}, | ||
getAttributes: function getAttributes(comp) { | ||
return comp.attribs; | ||
}, | ||
getChildren: function getChildren(comp) { | ||
return comp.children && [].concat([], comp.children) || []; | ||
} | ||
}; | ||
function getContains(actual, expected, options) { | ||
return (0, _contains2['default'])(TestAdapter, TestAdapter, actual, expected, expect, options); | ||
return (0, _contains2['default'])(_mockEntities.TestActualAdapter, _mockEntities.TestExpectedAdapter, actual, expected, expect, options); | ||
} | ||
@@ -49,3 +37,3 @@ | ||
return (0, _contains2['default'])(TestAdapter, TestAdapter, subject, value, expect, {}).then(function (result) { | ||
return (0, _contains2['default'])(_mockEntities.TestActualAdapter, _mockEntities.TestExpectedAdapter, subject, value, expect, {}).then(function (result) { | ||
expect.shift(result); | ||
@@ -57,3 +45,3 @@ }); | ||
return (0, _contains2['default'])(TestAdapter, TestAdapter, subject, value, expect, options).then(function (result) { | ||
return (0, _contains2['default'])(_mockEntities.TestActualAdapter, _mockEntities.TestExpectedAdapter, subject, value, expect, options).then(function (result) { | ||
expect.shift(result); | ||
@@ -66,7 +54,7 @@ }); | ||
it('finds an exact match', function () { | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { found: true }); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { found: true }); | ||
}); | ||
it('reports the inspection of the found item', function () { | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { | ||
found: true, | ||
@@ -84,13 +72,13 @@ bestMatch: { | ||
it('reports not found when no exact match exists', function () { | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some other content'] }, 'to satisfy', { found: false }); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some other content'] }), 'to satisfy', { found: false }); | ||
}); | ||
it('finds an element nested one deep', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { found: true }); | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { found: true }); | ||
}); | ||
it('finds a deep nested element', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['blah'] }, { name: 'span', attribs: { className: 'foo' }, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] }, { name: 'span', attribs: { className: 'foo' }, children: ['blubs'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { found: true, bestMatch: { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['blah'] }, { name: 'span', attribs: { className: 'foo' }, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] }, { name: 'span', attribs: { className: 'foo' }, children: ['blubs'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { found: true, bestMatch: { | ||
diff: { | ||
@@ -105,4 +93,4 @@ type: 'ELEMENT', | ||
it('finds a best match when the content is different', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { found: false, bestMatchItem: { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { found: false, bestMatchItem: { | ||
name: 'span', attribs: { className: 'foo' }, children: ['some different content'] | ||
@@ -113,4 +101,4 @@ } }); | ||
it('finds a best match in an array of children with an extra attribute', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, { name: 'span', attribs: { className: 'bar' }, children: ['some content'] }, { name: 'span', attribs: { className: 'candidate', id: 'abc' }, children: ['some content'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'candidate' }, children: ['some content'] }, 'to satisfy', { found: false, bestMatchItem: { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, { name: 'span', attribs: { className: 'bar' }, children: ['some content'] }, { name: 'span', attribs: { className: 'candidate', id: 'abc' }, children: ['some content'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'candidate' }, children: ['some content'] }), 'to satisfy', { found: false, bestMatchItem: { | ||
name: 'span', attribs: { className: 'candidate', id: 'abc' }, children: ['some content'] | ||
@@ -121,4 +109,4 @@ } }); | ||
it('returns a diff when the content is different', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { | ||
found: false, | ||
@@ -153,7 +141,7 @@ bestMatch: { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: {}, children: [searchItem] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: false, | ||
@@ -165,3 +153,3 @@ bestMatchItem: searchItem | ||
it('doesn\'t include wrappers in the bestMatch around the item that is found', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: {}, children: [{ | ||
@@ -174,5 +162,5 @@ name: 'div', attribs: {}, children: [{ | ||
}] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: false, | ||
@@ -193,3 +181,3 @@ bestMatch: { | ||
it('doesn\'t include wrappers in the bestMatch around an item that is found to match', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: {}, children: [{ | ||
@@ -202,5 +190,5 @@ name: 'div', attribs: {}, children: [{ | ||
}] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: true, | ||
@@ -221,3 +209,3 @@ bestMatch: { | ||
it('finds a nested component with missing children and extra attribute', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: {}, children: [{ | ||
@@ -236,3 +224,3 @@ name: 'span', | ||
}] | ||
}, 'when checked with options to contain', { diffExtraChildren: false, diffExtraAttributes: false }, { | ||
}), 'when checked with options to contain', { diffExtraChildren: false, diffExtraAttributes: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ | ||
@@ -243,3 +231,3 @@ name: 'span', | ||
}] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: true, | ||
@@ -246,0 +234,0 @@ bestMatch: { |
@@ -13,22 +13,8 @@ 'use strict'; | ||
var _mockEntities = require('./mockEntities'); | ||
var expect = _unexpected2['default'].clone(); | ||
var TestAdapter = { | ||
getName: function getName(comp) { | ||
return comp.name; | ||
}, | ||
getAttributes: function getAttributes(comp) { | ||
return comp.attribs; | ||
}, | ||
getChildren: function getChildren(comp) { | ||
return comp.children && [].concat([], comp.children) || []; | ||
}, | ||
classAttributeName: 'className' | ||
}; | ||
function getDiff(actual, expected, options) { | ||
return _diff2['default'].diffElements(TestAdapter, TestAdapter, actual, expected, expect, options); | ||
return _diff2['default'].diffElements(_mockEntities.TestActualAdapter, _mockEntities.TestExpectedAdapter, actual, expected, expect, options); | ||
} | ||
@@ -61,3 +47,3 @@ | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -75,3 +61,3 @@ type: 'ELEMENT', | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: { className: 'bar' }, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'bar' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -93,3 +79,3 @@ attributes: [{ | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: {}, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -110,3 +96,3 @@ attributes: [{ | ||
return expect({ name: 'span', attribs: { id: 'abc', className: 'foo' }, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: { id: 'abcd' }, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { id: 'abc', className: 'foo' }, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { id: 'abcd' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -134,3 +120,3 @@ attributes: [{ | ||
return expect({ name: 'span', attribs: {}, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -151,3 +137,3 @@ attributes: [{ | ||
return expect({ name: 'span', attribs: {}, children: ['some text'] }, 'when diffed against', { name: 'span', attribs: {}, children: ['some changed text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: ['some changed text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -169,3 +155,3 @@ children: [{ | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }, 'when diffed against', { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -203,7 +189,7 @@ children: [{ | ||
it('diffs a removed middle child', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child3'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -242,3 +228,3 @@ children: [{ | ||
it('diffs an extra last child', function () { | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'when diffed against', { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -277,3 +263,3 @@ children: [{ | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'when diffed against', { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -312,3 +298,3 @@ children: [{ | ||
it('diffs a changed middle child', function () { | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2 changed'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'when diffed against', { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2 changed'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -347,5 +333,32 @@ children: [{ | ||
it('diffs an out of order element', function () { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'Test', attribs: {}, children: ['one'] }, { name: 'Test', attribs: {}, children: ['two'] }, { name: 'Test', attribs: {}, children: ['three'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'Test', attribs: {}, children: ['one'] }, { name: 'Test', attribs: {}, children: ['three'] }, { name: 'Test', attribs: {}, children: ['two'] }] }), 'to satisfy', { | ||
diff: { | ||
children: [{ | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [{ type: 'CONTENT', value: 'one' }] | ||
}, { | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [{ type: 'CONTENT', value: 'three' }], | ||
diff: { type: 'missing', actualIndex: 2 } | ||
}, { | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [{ type: 'CONTENT', value: 'two' }] | ||
}, { | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [{ type: 'CONTENT', value: 'three' }], | ||
diff: { type: 'extra' } | ||
}] | ||
} | ||
}); | ||
}); | ||
it('diffs a missing content entry', function () { | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: ['child1', 'child3'] }, 'when diffed against', { name: 'span', attribs: {}, children: ['child1', 'child2', 'child3'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: ['child1', 'child3'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: ['child1', 'child2', 'child3'] }), 'to satisfy', { | ||
diff: { | ||
@@ -372,3 +385,3 @@ children: [{ | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: ['child1', 'child2', 'child3'] }, 'when diffed against', { name: 'span', attribs: {}, children: ['child1', 'child3'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: ['child1', 'child2', 'child3'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: ['child1', 'child3'] }), 'to satisfy', { | ||
diff: { | ||
@@ -394,3 +407,3 @@ children: [{ | ||
it('diffs a changed element name', function () { | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -411,3 +424,3 @@ type: 'ELEMENT', | ||
it('diffs a content-should-be-element', function () { | ||
return expect('some content', 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, 'to satisfy', { | ||
return expect('some content', 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -431,3 +444,3 @@ type: 'CONTENT', | ||
it('diffs a element-should-be-content', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, 'when diffed with options against', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), 'when diffed with options against', { | ||
weights: { NATIVE_NONNATIVE_MISMATCH: 1 } // Need to fool the weight to force this, otherwise it's a wrapper | ||
@@ -453,3 +466,3 @@ }, 'some content', 'to satisfy', { | ||
it('diffs a wrapper around a single child', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -477,3 +490,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around a single child', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -501,3 +514,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around multiple children', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -521,6 +534,6 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around each of several children', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }] | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }] | ||
}, { name: 'wrapper', attribs: { className: 'the-wrapper-2' }, children: [{ name: 'real', attribs: { className: 'real-element-2' } }] | ||
}, { name: 'wrapper', attribs: { className: 'the-wrapper-3' }, children: [{ name: 'real', attribs: { className: 'real-element-3' } }] | ||
}] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }, 'to satisfy', { | ||
}] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -561,5 +574,5 @@ type: 'ELEMENT', | ||
it('diffs a simple wrapper with diffWrappers:false', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }, 'when diffed with options against', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }] }), 'when diffed with options against', { | ||
diffWrappers: false | ||
}, { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }, 'to satisfy', { | ||
}, (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -584,3 +597,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around multiple children with diffWrappers:false', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }] }, 'when diffed with options against', { diffWrappers: false }, { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }] }), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -613,6 +626,6 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around each of several children with diffWrappers:false', function () { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }] | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }] | ||
}, { name: 'wrapper', attribs: { className: 'the-wrapper-2' }, children: [{ name: 'real', attribs: { className: 'real-element-2' } }] | ||
}, { name: 'wrapper', attribs: { className: 'the-wrapper-3' }, children: [{ name: 'real', attribs: { className: 'real-element-3' } }] | ||
}] }, 'when diffed with options against', { diffWrappers: false }, { name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }, 'to satisfy', { | ||
}] }), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ name: 'div', attribs: { className: 'foo' }, children: [{ name: 'real', attribs: { className: 'real-element-1' } }, { name: 'real', attribs: { className: 'real-element-2' } }, { name: 'real', attribs: { className: 'real-element-3' } }] }), 'to satisfy', { | ||
diff: { | ||
@@ -656,7 +669,7 @@ type: 'ELEMENT', | ||
it('ignores a top level wrapper with diffWrappers:false', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -676,9 +689,9 @@ type: 'WRAPPERELEMENT', | ||
it('ignores two levels of wrapper with diffWrappers:false', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -704,3 +717,3 @@ type: 'WRAPPERELEMENT', | ||
it('ignores missing children if diffMissingChildren:false', function () { | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }, 'when diffed with options against', { diffMissingChildren: false }, { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }), 'when diffed with options against', { diffMissingChildren: false }, (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -714,3 +727,3 @@ children: expect.it('to have length', 2) | ||
it('ignores extra children if diffExtraChildren:false', function () { | ||
return expect({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }, 'when diffed with options against', { diffExtraChildren: false }, { name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }, 'to satisfy', { | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }, { name: 'child', attribs: {}, children: ['child3'] }] }), 'when diffed with options against', { diffExtraChildren: false }, (0, _mockEntities.createExpected)({ name: 'span', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['child1'] }, { name: 'child', attribs: {}, children: ['child2'] }] }), 'to satisfy', { | ||
diff: { | ||
@@ -732,3 +745,3 @@ children: [{}, {}, { | ||
it('ignores missing attributes if diffRemovedAttributes:false', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'span', | ||
@@ -739,3 +752,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffRemovedAttributes: false }, { | ||
}), 'when diffed with options against', { diffRemovedAttributes: false }, (0, _mockEntities.createExpected)({ | ||
name: 'span', | ||
@@ -747,3 +760,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -759,3 +772,3 @@ type: 'ELEMENT', | ||
it('ignores extra attributes if diffExtraAttributes:false', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'span', | ||
@@ -767,3 +780,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: false }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: false }, (0, _mockEntities.createExpected)({ | ||
name: 'span', | ||
@@ -774,3 +787,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -786,3 +799,3 @@ type: 'ELEMENT', | ||
it('treats undefined attributes as not defined', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'span', | ||
@@ -794,3 +807,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: true }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: true }, (0, _mockEntities.createExpected)({ | ||
name: 'span', | ||
@@ -801,3 +814,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -813,3 +826,3 @@ type: 'ELEMENT', | ||
it('treats null attributes as defined', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'span', | ||
@@ -821,3 +834,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: true }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: true }, (0, _mockEntities.createExpected)({ | ||
name: 'span', | ||
@@ -828,3 +841,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -840,11 +853,11 @@ type: 'ELEMENT', | ||
it("doesn't wrap an element when it means there are missing children", function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [{ name: 'ThisIsNotAWrapper', attribs: {}, children: [] }] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [{ name: 'ExpectedElement', attribs: {}, children: [] }] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -868,11 +881,11 @@ type: 'ELEMENT', | ||
it('diffs extra children when the expected has no children but wrappers are allowed', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [{ name: 'div', attribs: {}, children: [] }] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -895,3 +908,3 @@ type: 'ELEMENT', | ||
it('accepts a passing expect.it attribute assertion', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -902,3 +915,3 @@ name: 'SomeElement', | ||
} | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
@@ -908,3 +921,3 @@ attribs: { | ||
} | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -923,3 +936,3 @@ type: 'ELEMENT', | ||
it('diffs an expect.it attribute assertion', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -930,3 +943,3 @@ name: 'SomeElement', | ||
} | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
@@ -936,3 +949,3 @@ attribs: { | ||
} | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -955,3 +968,3 @@ type: 'ELEMENT', | ||
it('diffs an expect.it content assertion', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -961,7 +974,7 @@ name: 'SomeElement', | ||
children: ['abcde'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [expect.it('to match', /[a-d]+$/)] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -985,3 +998,3 @@ type: 'ELEMENT', | ||
it('returns a CONTENT type for a passed content assertion', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -991,7 +1004,7 @@ name: 'SomeElement', | ||
children: ['abcd'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [expect.it('to match', /[a-d]+$/)] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1015,3 +1028,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1021,3 +1034,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: true }, { | ||
}), 'when diffed with options against', { diffExactClasses: true }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1027,3 +1040,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1046,3 +1059,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1052,3 +1065,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1058,3 +1071,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1074,3 +1087,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1080,3 +1093,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1086,3 +1099,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1105,3 +1118,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1111,3 +1124,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1117,3 +1130,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1136,3 +1149,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1142,3 +1155,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1148,3 +1161,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1168,3 +1181,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1174,3 +1187,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1180,3 +1193,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1200,3 +1213,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1206,3 +1219,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1212,3 +1225,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1232,3 +1245,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1238,3 +1251,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1244,3 +1257,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1260,3 +1273,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1266,3 +1279,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1272,3 +1285,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1290,3 +1303,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
type: 'ELEMENT', | ||
@@ -1296,3 +1309,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffMissingClasses: false }, { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffMissingClasses: false }, (0, _mockEntities.createExpected)({ | ||
type: 'ELEMENT', | ||
@@ -1302,3 +1315,3 @@ name: 'SomeElement', | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1305,0 +1318,0 @@ type: 'ELEMENT', |
@@ -34,17 +34,6 @@ | ||
var _mockEntities = require('./mockEntities'); | ||
var expect = _unexpected2['default'].clone(); | ||
var TestAdapter = { | ||
getName: function getName(comp) { | ||
return comp.name; | ||
}, | ||
getAttributes: function getAttributes(comp) { | ||
return comp.attribs; | ||
}, | ||
getChildren: function getChildren(comp) { | ||
return [].concat([], comp.children); | ||
} | ||
}; | ||
expect.output.preferredWidth = 80; | ||
@@ -59,3 +48,3 @@ | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter, TestAdapter); | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
return htmlLikeUnexpected.inspect(value, depth, output, _inspect); | ||
@@ -65,3 +54,3 @@ }, | ||
diff: function diff(actual, expected, output, _diff, inspect) { | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter, TestAdapter); | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
return htmlLikeUnexpected.inspect(value, depth, output, inspect); | ||
@@ -77,5 +66,5 @@ } | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter); | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
var pen = expect.output.clone(); | ||
return htmlLikeUnexpected.diff(TestAdapter, subject, value, pen, expect).then(function (result) { | ||
return htmlLikeUnexpected.diff(_mockEntities.TestExpectedAdapter, subject, value, pen, expect).then(function (result) { | ||
@@ -88,6 +77,6 @@ return expect.shift(result); | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter); | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
var pen = expect.output.clone(); | ||
return htmlLikeUnexpected.diff(TestAdapter, subject, value, pen, expect, options).then(function (result) { | ||
return htmlLikeUnexpected.diff(_mockEntities.TestExpectedAdapter, subject, value, pen, expect, options).then(function (result) { | ||
@@ -163,4 +152,4 @@ return expect.shift(result); | ||
expect.addAssertion('<TestHtmlLike> when checked to contain <TestHtmlLike> <assertion>', function (expect, subject, value) { | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter); | ||
return htmlLikeUnexpected.contains(TestAdapter, subject, value, expect.output, expect, null).then(function (result) { | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
return htmlLikeUnexpected.contains(_mockEntities.TestExpectedAdapter, subject, value, expect.output, expect, null).then(function (result) { | ||
expect.shift(result); | ||
@@ -171,4 +160,4 @@ }); | ||
expect.addAssertion('<TestHtmlLike> when checked with options to contain <object> <TestHtmlLike> <assertion>', function (expect, subject, options, value) { | ||
var htmlLikeUnexpected = new _index2['default'](TestAdapter); | ||
return htmlLikeUnexpected.contains(TestAdapter, subject, value, expect.output, expect, options).then(function (result) { | ||
var htmlLikeUnexpected = new _index2['default'](_mockEntities.TestActualAdapter); | ||
return htmlLikeUnexpected.contains(_mockEntities.TestExpectedAdapter, subject, value, expect.output, expect, options).then(function (result) { | ||
expect.shift(result); | ||
@@ -220,3 +209,3 @@ }); | ||
it('outputs a formatted output with no children', function () { | ||
expect({ name: 'div', attribs: { id: 'foo', className: 'bar' }, children: [] }, 'to inspect as', '<div id="foo" className="bar" />'); | ||
expect((0, _mockEntities.createActual)({ name: 'div', attribs: { id: 'foo', className: 'bar' }, children: [] }), 'to inspect as', '<div id="foo" className="bar" />'); | ||
}); | ||
@@ -226,3 +215,3 @@ | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo', className: 'bar' }, children: [{ | ||
@@ -237,9 +226,9 @@ name: 'span', | ||
}] | ||
}, 'to inspect as', '<div id="foo" className="bar">\n' + ' <span className="child1">child content 1</span>\n' + ' <span className="child2">child content 2</span>\n' + '</div>'); | ||
}), 'to inspect as', '<div id="foo" className="bar">\n' + ' <span className="child1">child content 1</span>\n' + ' <span className="child2">child content 2</span>\n' + '</div>'); | ||
}); | ||
it('outputs object attributes', function () { | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { style: { width: 125, height: 100 } }, children: [] | ||
}, 'to inspect as', '<div style={{ width: 125, height: 100 }} />'); | ||
}), 'to inspect as', '<div style={{ width: 125, height: 100 }} />'); | ||
}); | ||
@@ -265,3 +254,3 @@ | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'outside-wrapper', className: 'wrap-me' }, children: [{ | ||
@@ -278,3 +267,3 @@ name: 'div', attribs: { id: 'foo', className: 'bar' }, children: [{ | ||
}] | ||
}, 'to inspect as', '<div id="outside-wrapper" className="wrap-me">\n' + ' <div id="foo" className="bar">\n' + ' <span className="child1">child content 1</span>\n' + ' <span className="child2">child content 2</span>\n' + ' </div>\n' + '</div>'); | ||
}), 'to inspect as', '<div id="outside-wrapper" className="wrap-me">\n' + ' <div id="foo" className="bar">\n' + ' <span className="child1">child content 1</span>\n' + ' <span className="child2">child content 2</span>\n' + ' </div>\n' + '</div>'); | ||
}); | ||
@@ -284,3 +273,3 @@ | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo', className: 'bar' }, children: [{ | ||
@@ -293,7 +282,7 @@ name: 'span', | ||
}] | ||
}, 'to inspect as', '<div id="foo" className="bar"><span>1</span><span>2</span></div>'); | ||
}), 'to inspect as', '<div id="foo" className="bar"><span>1</span><span>2</span></div>'); | ||
}); | ||
it('outputs attributes on split lines if they are too long, with no content', function () { | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { | ||
@@ -306,7 +295,7 @@ id: 'foo', | ||
children: [] | ||
}, 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib"\n' + '/>'); | ||
}), 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib"\n' + '/>'); | ||
}); | ||
it('outputs attributes on split lines if they are too long, with content', function () { | ||
expect({ | ||
expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { | ||
@@ -319,3 +308,3 @@ id: 'foo', | ||
children: ['some content'] | ||
}, 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib">\n' + ' some content\n' + '</div>'); | ||
}), 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib">\n' + ' some content\n' + '</div>'); | ||
}); | ||
@@ -327,7 +316,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'bar' }, children: [] | ||
}, 'to have weight', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to have weight', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -337,15 +326,15 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'bar' }, children: [] | ||
}, 'to output', '<div id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + '/>'); | ||
}), 'to output', '<div id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + '/>'); | ||
}); | ||
it('outputs attributes that are different types but evaluate to the same string', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: '42' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 42 }, children: [] | ||
}, 'to output with weight', '<div id="42" // should be id={42}\n' + '/>', _diff5['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to output with weight', '<div id="42" // should be id={42}\n' + '/>', _diff5['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -355,7 +344,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo', className: 'testing' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'bar', className: 'testing' }, children: [] | ||
}, 'to output', '<div id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + ' className="testing"\n' + '/>'); | ||
}), 'to output', '<div id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + ' className="testing"\n' + '/>'); | ||
}); | ||
@@ -365,7 +354,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { className: 'testing', id: 'foo' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { className: 'testing', id: 'bar' }, children: [] | ||
}, 'to output', '<div className="testing" id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + '/>'); | ||
}), 'to output', '<div className="testing" id="foo" // should be id="bar"\n' + ' // -foo\n' + ' // +bar\n' + '/>'); | ||
}); | ||
@@ -391,23 +380,23 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: actualAttribs, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: expectedAttribs, children: [] | ||
}, 'to output', '<div data-attrib1="aaa" data-attrib2="hello world" data-attrib3="testing is fun"\n' + ' data-attrib4="hallo welt" data-attrib5="jonny number five"\n' + ' data-mismatch="foo" // should be data-mismatch="bar"\n' + ' // -foo\n' + ' // +bar\n' + ' data-after="bbb" data-after2="ccc some more words"\n' + ' data-after3="here is some more"\n' + '/>'); | ||
}), 'to output', '<div data-attrib1="aaa" data-attrib2="hello world" data-attrib3="testing is fun"\n' + ' data-attrib4="hallo welt" data-attrib5="jonny number five"\n' + ' data-mismatch="foo" // should be data-mismatch="bar"\n' + ' // -foo\n' + ' // +bar\n' + ' data-after="bbb" data-after2="ccc some more words"\n' + ' data-after3="here is some more"\n' + '/>'); | ||
}); | ||
it('highlights a missing attribute', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { className: 'testing', id: 'foo' }, children: [] | ||
}, 'to output', '<div id="foo" // missing className="testing"\n' + '/>'); | ||
}), 'to output', '<div id="foo" // missing className="testing"\n' + '/>'); | ||
}); | ||
it('highlights two missing attributes', function () { | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { className: 'testing', id: 'foo', extra: '123' }, children: [] | ||
}, 'to output', '<div id="foo" // missing className="testing"\n' + ' // missing extra="123"\n' + '/>'); | ||
}), 'to output', '<div id="foo" // missing className="testing"\n' + ' // missing extra="123"\n' + '/>'); | ||
}); | ||
@@ -417,7 +406,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: ['abc'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: ['def'] | ||
}, 'to output with weight', '<div id="foo">\n' + ' -abc\n' + ' +def\n' + '</div>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' -abc\n' + ' +def\n' + '</div>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}); | ||
@@ -427,7 +416,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: ['42'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [42] | ||
}, 'to output with weight', '<div id="foo">\n' + ' 42 // mismatched type -string\n' + ' // +number\n' + '</div>', _index2['default'].DefaultWeights.CONTENT_TYPE_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' 42 // mismatched type -string\n' + ' // +number\n' + '</div>', _index2['default'].DefaultWeights.CONTENT_TYPE_MISMATCH); | ||
}); | ||
@@ -437,7 +426,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['updated'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span>one</span>\n' + ' <span>\n' + ' -two\n' + ' +updated\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span>one</span>\n' + ' <span>\n' + ' -two\n' + ' +updated\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}); | ||
@@ -447,7 +436,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'div', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <div // should be <span\n' + ' >\n' + ' one\n' + ' </div>\n' + ' <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.NAME_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <div // should be <span\n' + ' >\n' + ' one\n' + ' </div>\n' + ' <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.NAME_MISMATCH); | ||
}); | ||
@@ -457,7 +446,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childbar' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo" // should be id="childbar"\n' + ' // -childfoo\n' + ' // +childbar\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo" // should be id="childbar"\n' + ' // -childfoo\n' + ' // +childbar\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -467,7 +456,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' // missing <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' // missing <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
}); | ||
@@ -477,7 +466,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' <span>two</span> // should be removed\n' + '</div>', _index2['default'].DefaultWeights.CHILD_INSERTED); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' <span>two</span> // should be removed\n' + '</div>', _index2['default'].DefaultWeights.CHILD_INSERTED); | ||
}); | ||
@@ -488,8 +477,8 @@ | ||
// override the weight for NATIVE_NONNATIVE_MISMATCH, otherwise a wrapper is preferred | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'when diffed with options against', { weights: { NATIVE_NONNATIVE_MISMATCH: 1 } }, { | ||
}), 'when diffed with options against', { weights: { NATIVE_NONNATIVE_MISMATCH: 1 } }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'some text'] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + " <span>two</span> // should be 'some text'\n" + '</div>', 1 // Overridden NATIVE_NONNATIVE_MISMATCH | ||
); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + " <span>two</span> // should be 'some text'\n" + '</div>', // Overridden NATIVE_NONNATIVE_MISMATCH | ||
1); | ||
}); | ||
@@ -499,7 +488,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: {}, children: ['two'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ name: 'child', attribs: {}, children: ['aa'] }] | ||
}, 'to output with weight', '<div>\n' + ' two // should be <child>aa</child>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}), 'to output with weight', '<div>\n' + ' two // should be <child>aa</child>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}); | ||
@@ -509,8 +498,8 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: [{ name: 'span', attribs: { className: 'deep' }, children: ['nested and broken over many lines because it is very long'] }] }] | ||
}, 'when diffed with options against', { weights: { NATIVE_NONNATIVE_MISMATCH: 1 } }, { | ||
}), 'when diffed with options against', { weights: { NATIVE_NONNATIVE_MISMATCH: 1 } }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'some text'] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + " <span> // should be 'some text'\n" + ' <span className="deep"> //\n' + ' nested and broken over many lines because it is very long //\n' + ' </span> //\n' + ' </span> //\n' + '</div>', 1 // Overridden weight to force a NATIVE_NONNATIVE_MISMATCH | ||
); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + " <span> // should be 'some text'\n" + ' <span className="deep"> //\n' + ' nested and broken over many lines because it is very long //\n' + ' </span> //\n' + ' </span> //\n' + '</div>', // Overridden weight to force a NATIVE_NONNATIVE_MISMATCH | ||
1); | ||
}); | ||
@@ -520,7 +509,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'some text'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' some text // should be <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' some text // should be <span>two</span>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}); | ||
@@ -530,7 +519,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'some text'] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: {}, children: [{ name: 'span', attribs: { className: 'deep' }, children: ['nested and broken over many lines because it is very long'] }] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' some text // should be <span>\n' + ' // <span className="deep">\n' + ' // nested and broken over many lines because it is very long\n' + ' // </span>\n' + ' // </span>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' some text // should be <span>\n' + ' // <span className="deep">\n' + ' // nested and broken over many lines because it is very long\n' + ' // </span>\n' + ' // </span>\n' + '</div>', _index2['default'].DefaultWeights.NATIVE_NONNATIVE_MISMATCH); | ||
}); | ||
@@ -544,7 +533,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo', extraAttribute: 'does not matter' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffExtraAttributes: false }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'to have weight', _index2['default'].DefaultWeights.OK); | ||
}), 'to have weight', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -554,7 +543,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo', 'data-extraAttribute': 'does matter' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffExtraAttributes: true }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: true }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo"\n' + ' data-extraAttribute="does matter" // data-extraAttribute should be removed\n' + ' >\n' + ' one\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_EXTRA); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo"\n' + ' data-extraAttribute="does matter" // data-extraAttribute should be removed\n' + ' >\n' + ' one\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_EXTRA); | ||
}); | ||
@@ -567,7 +556,7 @@ }); | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffRemovedAttributes: true }, { | ||
}), 'when diffed with options against', { diffRemovedAttributes: true }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo', removedAttribute: 'does matter' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo" // missing removedAttribute="does matter"\n' + ' >\n' + ' one\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_MISSING); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo" // missing removedAttribute="does matter"\n' + ' >\n' + ' one\n' + ' </span>\n' + '</div>', _index2['default'].DefaultWeights.ATTRIBUTE_MISSING); | ||
}); | ||
@@ -577,7 +566,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffRemovedAttributes: false }, { | ||
}), 'when diffed with options against', { diffRemovedAttributes: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo', 'data-removedAttribute': 'does matter' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo"><span id="childfoo">one</span></div>', _index2['default'].DefaultWeights.OK); | ||
}), 'to output with weight', '<div id="foo"><span id="childfoo">one</span></div>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -590,7 +579,7 @@ }); | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffMissingChildren: true }, { | ||
}), 'when diffed with options against', { diffMissingChildren: true }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'removed-child' }, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' // missing <span id="removed-child">two</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' // missing <span id="removed-child">two</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
}); | ||
@@ -600,7 +589,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'when diffed with options against', { diffMissingChildren: false }, { | ||
}), 'when diffed with options against', { diffMissingChildren: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'removed-child' }, children: ['two'] }] | ||
}, 'to output with weight', '<div id="foo"><span id="childfoo">one</span></div>', _index2['default'].DefaultWeights.OK); | ||
}), 'to output with weight', '<div id="foo"><span id="childfoo">one</span></div>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -613,7 +602,7 @@ }); | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'extra-child' }, children: ['two'] }] | ||
}, 'when diffed with options against', { diffExtraChildren: true }, { | ||
}), 'when diffed with options against', { diffExtraChildren: true }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' <span id="extra-child">two</span> // should be removed\n' + '</div>', _index2['default'].DefaultWeights.CHILD_INSERTED); | ||
}), 'to output with weight', '<div id="foo">\n' + ' <span id="childfoo">one</span>\n' + ' <span id="extra-child">two</span> // should be removed\n' + '</div>', _index2['default'].DefaultWeights.CHILD_INSERTED); | ||
}); | ||
@@ -623,7 +612,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'extra-child' }, children: ['two'] }] | ||
}, 'when diffed with options against', { diffExtraChildren: false }, { | ||
}), 'when diffed with options against', { diffExtraChildren: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: { id: 'foo' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}, 'to output with weight', '<div id="foo"><span id="childfoo">one</span><span id="extra-child">two</span></div>', _index2['default'].DefaultWeights.OK); | ||
}), 'to output with weight', '<div id="foo"><span id="childfoo">one</span><span id="extra-child">two</span></div>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -637,11 +626,11 @@ }); | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ | ||
name: 'div', attribs: { id: 'wrapper' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] | ||
}] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ | ||
name: 'span', attribs: { id: 'childfoo' }, children: ['one'] | ||
}] | ||
}, 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}), 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}); | ||
@@ -651,9 +640,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ | ||
name: 'div', attribs: { id: 'wrapper' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span><span id="childfoo">two</span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}), 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span><span id="childfoo">two</span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}); | ||
@@ -663,9 +652,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ | ||
name: 'div', attribs: { id: 'wrapper' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'other' }, children: ['changed'] }] | ||
}, 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' <span id="childfoo" // should be id="other"\n' + ' // -childfoo\n' + ' // +other\n' + ' >\n' + ' -two\n' + ' +changed\n' + ' </span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED + _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH + _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}), 'to output with weight', '<body id="main">\n' + ' <div id="wrapper"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' <span id="childfoo" // should be id="other"\n' + ' // -childfoo\n' + ' // +other\n' + ' >\n' + ' -two\n' + ' +changed\n' + ' </span>\n' + ' </div> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED + _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH + _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}); | ||
@@ -675,7 +664,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'childWrapper', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] }, { name: 'childWrapper', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<body id="main">\n' + ' <childWrapper> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper> // wrapper should be removed\n' + ' <childWrapper> // wrapper should be removed\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}), 'to output with weight', '<body id="main">\n' + ' <childWrapper> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper> // wrapper should be removed\n' + ' <childWrapper> // wrapper should be removed\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}); | ||
@@ -685,7 +674,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'childWrapper', attribs: { id: 'wrapper1' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] }, { name: 'childWrapper', attribs: { id: 'wrapper2' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<body id="main">\n' + ' <childWrapper id="wrapper1"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper> // wrapper should be removed\n' + ' <childWrapper id="wrapper2"> // wrapper should be removed\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}), 'to output with weight', '<body id="main">\n' + ' <childWrapper id="wrapper1"> // wrapper should be removed\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper> // wrapper should be removed\n' + ' <childWrapper id="wrapper2"> // wrapper should be removed\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper> // wrapper should be removed\n' + '</body>', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}); | ||
@@ -695,7 +684,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'childWrapper', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }] }, { name: 'childWrapper', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'body', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<body id="main">\n' + ' <childWrapper>\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper>\n' + ' <childWrapper>\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper>\n' + '</body>', _index2['default'].DefaultWeights.OK); | ||
}), 'to output with weight', '<body id="main">\n' + ' <childWrapper>\n' + ' <span id="childfoo">one</span>\n' + ' </childWrapper>\n' + ' <childWrapper>\n' + ' <span id="childfoo">two</span>\n' + ' </childWrapper>\n' + '</body>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -708,9 +697,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<HigherOrderTopLevel id="main"> // wrapper should be removed\n' + ' <TopLevel><span id="childfoo">one</span><span id="childfoo">two</span></TopLevel>\n' + '</HigherOrderTopLevel> // wrapper should be removed', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}), 'to output with weight', '<HigherOrderTopLevel id="main"> // wrapper should be removed\n' + ' <TopLevel><span id="childfoo">one</span><span id="childfoo">two</span></TopLevel>\n' + '</HigherOrderTopLevel> // wrapper should be removed', _index2['default'].DefaultWeights.WRAPPER_REMOVED); | ||
}); | ||
@@ -720,9 +709,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<HigherOrderTopLevel id="main"> // wrapper should be removed\n' + ' <TopLevel> // wrapper should be removed\n' + ' <MidLevel><span id="childfoo">one</span><span id="childfoo">two</span></MidLevel>\n' + ' </TopLevel> // wrapper should be removed\n' + '</HigherOrderTopLevel> // wrapper should be removed', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}), 'to output with weight', '<HigherOrderTopLevel id="main"> // wrapper should be removed\n' + ' <TopLevel> // wrapper should be removed\n' + ' <MidLevel><span id="childfoo">one</span><span id="childfoo">two</span></MidLevel>\n' + ' </TopLevel> // wrapper should be removed\n' + '</HigherOrderTopLevel> // wrapper should be removed', _index2['default'].DefaultWeights.WRAPPER_REMOVED * 2); | ||
}); | ||
@@ -732,9 +721,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <TopLevel>\n' + ' <MidLevel><span id="childfoo">one</span><span id="childfoo">two</span></MidLevel>\n' + ' </TopLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.OK); | ||
}), 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <TopLevel>\n' + ' <MidLevel><span id="childfoo">one</span><span id="childfoo">two</span></MidLevel>\n' + ' </TopLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -744,9 +733,9 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
name: 'TopLevel', attribs: { id: 'main' }, children: [{ name: 'MidLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] }] | ||
}] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'TopLevel', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['changed'] }] | ||
}, 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <TopLevel id="main">\n' + ' <MidLevel>\n' + ' <span id="childfoo">one</span>\n' + ' <span id="childfoo">\n' + ' -two\n' + ' +changed\n' + ' </span>\n' + ' </MidLevel>\n' + ' </TopLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}), 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <TopLevel id="main">\n' + ' <MidLevel>\n' + ' <span id="childfoo">one</span>\n' + ' <span id="childfoo">\n' + ' -two\n' + ' +changed\n' + ' </span>\n' + ' </MidLevel>\n' + ' </TopLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}); | ||
@@ -756,3 +745,3 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ | ||
@@ -763,4 +752,4 @@ name: 'MidLevel', attribs: {}, children: [{ | ||
}] | ||
}, 'when diffed with options against', { diffWrappers: false }, { name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <MidLevel>\n' + ' <LowLevel id="lower">\n' + ' <span id="childfoo">one</span><span id="childfoo">two</span>\n' + ' </LowLevel>\n' + ' </MidLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.OK); | ||
}), 'when diffed with options against', { diffWrappers: false }, (0, _mockEntities.createExpected)({ name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}), 'to output with weight', '<HigherOrderTopLevel id="main">\n' + ' <MidLevel>\n' + ' <LowLevel id="lower">\n' + ' <span id="childfoo">one</span><span id="childfoo">two</span>\n' + ' </LowLevel>\n' + ' </MidLevel>\n' + '</HigherOrderTopLevel>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -773,3 +762,3 @@ }); | ||
it('finds an exact match', function () { | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to satisfy', { found: true }); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to satisfy', { found: true }); | ||
}); | ||
@@ -779,3 +768,3 @@ | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some other content'] }, 'to satisfy', { found: false }); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some other content'] }), 'to satisfy', { found: false }); | ||
}); | ||
@@ -785,4 +774,4 @@ | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: ['some content'] }, 'to output', '<span className="foo">\n' + ' -some different content\n' + ' +some content\n' + '</span>'); | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some different content'] }] | ||
}), 'when checked to contain', (0, _mockEntities.createExpected)({ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }), 'to output', '<span className="foo">\n' + ' -some different content\n' + ' +some content\n' + '</span>'); | ||
}); | ||
@@ -792,3 +781,3 @@ | ||
return expect({ name: 'body', attribs: {}, children: [{ name: 'div', attribs: {}, children: [{ | ||
return expect((0, _mockEntities.createActual)({ name: 'body', attribs: {}, children: [{ name: 'div', attribs: {}, children: [{ | ||
name: 'wrapper', attribs: { className: 'the-wrapper' }, | ||
@@ -798,3 +787,3 @@ children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}] | ||
}] }, 'when checked with options to contain', { diffWrappers: false }, { name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] }, 'to satisfy', { found: true }); | ||
}] }), 'when checked with options to contain', { diffWrappers: false }, (0, _mockEntities.createExpected)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] }), 'to satisfy', { found: true }); | ||
}); | ||
@@ -804,3 +793,3 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'body', attribs: {}, children: [{ | ||
@@ -813,5 +802,5 @@ name: 'div', attribs: {}, children: [{ | ||
}] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, (0, _mockEntities.createExpected)({ | ||
name: 'div', attribs: {}, children: [{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] }] | ||
}, 'to output', '<div>\n' + ' <wrapper className="the-wrapper">\n' + ' <span className="foo">\n' + ' -some different content\n' + ' +some content\n' + ' </span>\n' + ' </wrapper>\n' + '</div>'); | ||
}), 'to output', '<div>\n' + ' <wrapper className="the-wrapper">\n' + ' <span className="foo">\n' + ' -some different content\n' + ' +some content\n' + ' </span>\n' + ' </wrapper>\n' + '</div>'); | ||
}); | ||
@@ -825,7 +814,7 @@ }); | ||
// This is nested deliberately, to ensure the deep promise is checked properly | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: expect.it('to match', /[a-f]+$/) }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // expected \'childfoo\' to match /[a-f]+$/\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // expected \'childfoo\' to match /[a-f]+$/\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -835,7 +824,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: expect.it('to match', /[a-f]+$/).and('to have length', 8) }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // ⨯ expected \'childfoo\' to match /[a-f]+$/ and\n' + ' // ✓ expected \'childfoo\' to have length 8\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // ⨯ expected \'childfoo\' to match /[a-f]+$/ and\n' + ' // ✓ expected \'childfoo\' to have length 8\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -845,7 +834,7 @@ | ||
return expect({ | ||
return expect((0, _mockEntities.createActual)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', (0, _mockEntities.createExpected)({ | ||
name: 'TopLevel', attribs: {}, children: [{ name: 'span', attribs: { id: expect.it('to match', /[a-f]+$/).and('to have length', 8) }, children: ['one'] }, { name: 'span', attribs: { id: 'childfoo' }, children: ['two'] }] | ||
}, 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // ⨯ expected \'childfoo\' to match /[a-f]+$/ and\n' + ' // ✓ expected \'childfoo\' to have length 8\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}), 'to output with weight', '<TopLevel>\n' + ' <span id="childfoo" // ⨯ expected \'childfoo\' to match /[a-f]+$/ and\n' + ' // ✓ expected \'childfoo\' to have length 8\n' + ' >\n' + ' one\n' + ' </span>\n' + ' <span id="childfoo">two</span>\n' + '</TopLevel>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -855,3 +844,3 @@ | ||
return expect({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'when diffed against', { name: 'span', attribs: { id: expect.it('to eventually have value', 'not childfoo') }, children: ['one'] }, 'to output with weight', '<span id="childfoo" // expected \'childfoo\' to eventually have value \'not childfoo\'\n' + '>\n' + ' one\n' + '</span>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { id: expect.it('to eventually have value', 'not childfoo') }, children: ['one'] }), 'to output with weight', '<span id="childfoo" // expected \'childfoo\' to eventually have value \'not childfoo\'\n' + '>\n' + ' one\n' + '</span>', _index2['default'].DefaultWeights.ATTRIBUTE_MISMATCH); | ||
}); | ||
@@ -861,3 +850,3 @@ | ||
return expect({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'when diffed against', { name: 'span', attribs: { id: expect.it('to eventually have value', 'childfoo') }, children: ['one'] }, 'to output with weight', '<span id="childfoo">one</span>', _index2['default'].DefaultWeights.OK); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { id: expect.it('to eventually have value', 'childfoo') }, children: ['one'] }), 'to output with weight', '<span id="childfoo">one</span>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
@@ -867,3 +856,3 @@ | ||
return expect({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'when diffed against', { name: 'span', attribs: { id: 'childfoo' }, children: [expect.it('to eventually have value', 'not one')] }, 'to output with weight', '<span id="childfoo">\n' + " one // expected 'one' to eventually have value 'not one'\n" + '</span>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { id: 'childfoo' }, children: [expect.it('to eventually have value', 'not one')] }), 'to output with weight', '<span id="childfoo">\n' + " one // expected 'one' to eventually have value 'not one'\n" + '</span>', _index2['default'].DefaultWeights.STRING_CONTENT_MISMATCH); | ||
}); | ||
@@ -873,7 +862,7 @@ | ||
return expect({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, 'when diffed against', { name: 'span', attribs: { id: 'childfoo' }, children: [expect.it('to eventually have value', 'one')] }, 'to output with weight', '<span id="childfoo">one</span>', _index2['default'].DefaultWeights.OK); | ||
return expect((0, _mockEntities.createActual)({ name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'span', attribs: { id: 'childfoo' }, children: [expect.it('to eventually have value', 'one')] }), 'to output with weight', '<span id="childfoo">one</span>', _index2['default'].DefaultWeights.OK); | ||
}); | ||
it('works out which children match best, with asynchronous expect.it assertions in the children', function () { | ||
return expect({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }, { name: 'span', attribs: {}, children: ['four'] }] }, 'when diffed against', { name: 'div', attribs: {}, children: [{ name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'one')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'two')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'three')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'four')] }] }, 'to output with weight', '<div>\n' + ' <span>one</span>\n' + ' <span>two</span>\n' + ' // missing <span>{expect.it(\'to eventually have value\', \'three\')}</span>\n' + ' <span>four</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
return expect((0, _mockEntities.createActual)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: {}, children: ['one'] }, { name: 'span', attribs: {}, children: ['two'] }, { name: 'span', attribs: {}, children: ['four'] }] }), 'when diffed against', (0, _mockEntities.createExpected)({ name: 'div', attribs: {}, children: [{ name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'one')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'two')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'three')] }, { name: 'span', attribs: {}, children: [expect.it('to eventually have value', 'four')] }] }), 'to output with weight', '<div>\n' + ' <span>one</span>\n' + ' <span>two</span>\n' + ' // missing <span>{expect.it(\'to eventually have value\', \'three\')}</span>\n' + ' <span>four</span>\n' + '</div>', _index2['default'].DefaultWeights.CHILD_MISSING); | ||
}); | ||
@@ -880,0 +869,0 @@ }); |
@@ -873,2 +873,36 @@ 'use strict'; | ||
it('outputs a moved element hint', function () { | ||
/* | ||
* This is where the actual is | ||
* <span> | ||
* <Test>one</Test> | ||
* <Test>three</Test> | ||
* <Test>two</Test> | ||
* </span> | ||
* | ||
* And should be one, two, three. | ||
*/ | ||
(0, _painter2['default'])(pen, { | ||
type: 'ELEMENT', | ||
name: 'span', | ||
attributes: [], | ||
children: [{ type: 'ELEMENT', name: 'Test', attributes: [], children: [{ type: 'CONTENT', value: 'one' }] }, { | ||
type: 'ELEMENT', name: 'Test', attributes: [], children: [{ type: 'CONTENT', value: 'two' }], | ||
diff: { | ||
type: 'missing', | ||
actualIndex: 2 | ||
} | ||
}, { type: 'ELEMENT', name: 'Test', attributes: [], children: [{ type: 'CONTENT', value: 'three' }] }, { | ||
type: 'ELEMENT', name: 'Test', attributes: [], children: [{ type: 'CONTENT', value: 'two' }], | ||
diff: { | ||
type: 'extra' | ||
} | ||
}] | ||
}); | ||
expect(pen.toString(), 'to equal', '<span>\n' + ' <Test>one</Test>\n' + ' // missing (found at index 2) <Test>two</Test>\n' + ' <Test>three</Test>\n' + ' <Test>two</Test> // should be removed\n' + '</span>'); | ||
}); | ||
describe('class differences', function () { | ||
@@ -875,0 +909,0 @@ |
{ | ||
"name": "unexpected-htmllike", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Helper library for unexpected plugins that perform assertions on XML like structures", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -99,3 +99,3 @@ // This code originally taken from array-changes https://github.com/unexpectedjs/array-changes | ||
type: 'insert', | ||
value: diffItem.values[i] | ||
value: diffItem.vlues[i] | ||
}; | ||
@@ -102,0 +102,0 @@ } |
@@ -542,3 +542,9 @@ import ArrayChangesAsync from 'array-changes-async'; | ||
insertCount++; | ||
itemResult = convertToDiff(expectedAdapter, diffItem.value); | ||
let actualIndex = null; | ||
if (typeof diffItem.actualIndex === 'number') { | ||
itemResult = convertToDiff(actualAdapter, diffItem.value); | ||
actualIndex = diffItem.actualIndex; | ||
} else { | ||
itemResult = convertToDiff(expectedAdapter, diffItem.value); | ||
} | ||
if (options.diffMissingChildren) { | ||
@@ -549,2 +555,7 @@ diffWeights.add(options.weights.CHILD_MISSING); | ||
}; | ||
if (actualIndex !== null) { | ||
itemResult.diff.actualIndex = actualIndex; | ||
} | ||
diffResult.push(itemResult); | ||
@@ -551,0 +562,0 @@ } |
@@ -16,2 +16,5 @@ | ||
this.error('missing').sp(); | ||
if (typeof description.diff.actualIndex === 'number') { | ||
this.error('(found at index ' + description.diff.actualIndex + ')').sp(); | ||
} | ||
this.block(function () { | ||
@@ -18,0 +21,0 @@ painter(this, { |
@@ -6,16 +6,16 @@ import Unexpected from 'unexpected'; | ||
import { | ||
expectedSymbol, | ||
actualSymbol, | ||
TestExpectedAdapter, | ||
TestActualAdapter, | ||
createActual, | ||
createExpected | ||
} from './mockEntities'; | ||
const expect = Unexpected.clone(); | ||
const TestAdapter = { | ||
getName(comp) { return comp.name; }, | ||
getAttributes(comp) { return comp.attribs; }, | ||
getChildren(comp) { | ||
return (comp.children && [].concat([], comp.children)) || []; | ||
} | ||
}; | ||
function getContains(actual, expected, options) { | ||
return Contains(TestAdapter, TestAdapter, actual, expected, expect, options); | ||
return Contains(TestActualAdapter, TestExpectedAdapter, actual, expected, expect, options); | ||
} | ||
@@ -37,3 +37,3 @@ | ||
return Contains(TestAdapter, TestAdapter, subject, value, expect, {}).then(result => { | ||
return Contains(TestActualAdapter, TestExpectedAdapter, subject, value, expect, {}).then(result => { | ||
expect.shift(result); | ||
@@ -46,3 +46,3 @@ }); | ||
return Contains(TestAdapter, TestAdapter, subject, value, expect, options).then(result => { | ||
return Contains(TestActualAdapter, TestExpectedAdapter, subject, value, expect, options).then(result => { | ||
expect.shift(result); | ||
@@ -55,9 +55,7 @@ }); | ||
it('finds an exact match', () => { | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, | ||
'when checked to contain', | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, | ||
'to satisfy', | ||
{ found: true } | ||
); | ||
return expect(createActual( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { found: true }); | ||
@@ -67,39 +65,37 @@ }); | ||
it('reports the inspection of the found item', () => { | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, | ||
'when checked to contain', | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, | ||
'to satisfy', | ||
{ | ||
found: true, | ||
bestMatch: { | ||
diff: { | ||
type: 'ELEMENT', | ||
name: 'span', | ||
attributes: [ { name: 'className', value: 'foo' } ] | ||
} | ||
return expect(createActual( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { | ||
found: true, | ||
bestMatch: { | ||
diff: { | ||
type: 'ELEMENT', | ||
name: 'span', | ||
attributes: [ { name: 'className', value: 'foo' } ] | ||
} | ||
} | ||
); | ||
}); | ||
}); | ||
it('reports not found when no exact match exists', () => { | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, | ||
'when checked to contain', | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some other content'] }, | ||
'to satisfy', | ||
{ found: false } | ||
); | ||
return expect(createActual( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some other content'] } | ||
), 'to satisfy', { found: false }); | ||
}); | ||
it('finds an element nested one deep', () => { | ||
return expect({ name: 'div', attribs: {}, children: [ | ||
return expect(createActual({ name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, 'to satisfy', { found: true }); | ||
}), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { found: true }); | ||
}); | ||
it('finds a deep nested element', () => { | ||
return expect({ name: 'div', attribs: {}, children: [ | ||
return expect(createActual({ name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'blah'] }, | ||
@@ -111,3 +107,5 @@ { name: 'span', attribs: { className: 'foo' }, children: [ | ||
] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, 'to satisfy', { found: true, bestMatch: { | ||
}), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { found: true, bestMatch: { | ||
diff: { | ||
@@ -122,6 +120,8 @@ type: 'ELEMENT', | ||
it('finds a best match when the content is different', () => { | ||
return expect({ name: 'div', attribs: {}, children: [ | ||
return expect(createActual({ name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some different content' ] } | ||
] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, 'to satisfy', { found: false, bestMatchItem: { | ||
}), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { found: false, bestMatchItem: { | ||
name: 'span', attribs: { className: 'foo' }, children: [ 'some different content' ] | ||
@@ -132,3 +132,3 @@ } }); | ||
it('finds a best match in an array of children with an extra attribute', () => { | ||
return expect({ name: 'div', attribs: {}, children: [ | ||
return expect(createActual({ name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content' ] }, | ||
@@ -138,3 +138,5 @@ { name: 'span', attribs: { className: 'bar' }, children: [ 'some content' ] }, | ||
] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'candidate' }, children: [ 'some content'] }, 'to satisfy', { found: false, bestMatchItem: { | ||
}), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'candidate' }, children: [ 'some content'] } | ||
), 'to satisfy', { found: false, bestMatchItem: { | ||
name: 'span', attribs: { className: 'candidate', id: 'abc' }, children: [ 'some content' ] | ||
@@ -145,6 +147,8 @@ } }); | ||
it('returns a diff when the content is different', () => { | ||
return expect({ name: 'div', attribs: {}, children: [ | ||
return expect(createActual({ name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some different content' ] } | ||
] | ||
}, 'when checked to contain', { name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] }, 'to satisfy', { | ||
}), 'when checked to contain', createExpected( | ||
{ name: 'span', attribs: { className: 'foo' }, children: [ 'some content'] } | ||
), 'to satisfy', { | ||
found: false, | ||
@@ -183,9 +187,9 @@ bestMatch: { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'body', attribs: {}, children: [ searchItem ] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, createExpected({ | ||
name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] } | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: false, | ||
@@ -197,3 +201,3 @@ bestMatchItem: searchItem | ||
it('doesn\'t include wrappers in the bestMatch around the item that is found', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'body', attribs: {}, children: [ { | ||
@@ -210,7 +214,7 @@ name: 'div', attribs: {}, children: [ | ||
} ] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, createExpected({ | ||
name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] } | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: false, | ||
@@ -231,3 +235,3 @@ bestMatch: { | ||
it('doesn\'t include wrappers in the bestMatch around an item that is found to match', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'body', attribs: {}, children: [{ | ||
@@ -244,7 +248,7 @@ name: 'div', attribs: {}, children: [ | ||
}] | ||
}, 'when checked with options to contain', { diffWrappers: false }, { | ||
}), 'when checked with options to contain', { diffWrappers: false }, createExpected({ | ||
name: 'div', attribs: {}, children: [ | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some content'] } | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: true, | ||
@@ -265,3 +269,3 @@ bestMatch: { | ||
it('finds a nested component with missing children and extra attribute', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'div', attribs: {}, children: [ | ||
@@ -284,3 +288,3 @@ { | ||
] | ||
}, 'when checked with options to contain', { diffExtraChildren: false, diffExtraAttributes: false }, { | ||
}), 'when checked with options to contain', { diffExtraChildren: false, diffExtraAttributes: false }, createExpected({ | ||
name: 'div', attribs: {}, children: [ | ||
@@ -293,3 +297,3 @@ { | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
found: true, | ||
@@ -296,0 +300,0 @@ bestMatch: { |
@@ -7,16 +7,14 @@ import Unexpected from 'unexpected'; | ||
const TestAdapter = { | ||
getName(comp) { return comp.name; }, | ||
import { | ||
expectedSymbol, | ||
actualSymbol, | ||
TestExpectedAdapter, | ||
TestActualAdapter, | ||
createActual, | ||
createExpected | ||
} from './mockEntities'; | ||
getAttributes(comp) { return comp.attribs; }, | ||
getChildren(comp) { | ||
return (comp.children && [].concat([], comp.children)) || []; | ||
}, | ||
classAttributeName: 'className' | ||
}; | ||
function getDiff(actual, expected, options) { | ||
return Diff.diffElements(TestAdapter, TestAdapter, actual, expected, expect, options); | ||
return Diff.diffElements(TestActualAdapter, TestExpectedAdapter, actual, expected, expect, options); | ||
} | ||
@@ -54,5 +52,5 @@ | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createActual({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createExpected({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'to satisfy', | ||
@@ -69,3 +67,4 @@ { | ||
weight: 0 | ||
}); | ||
} | ||
); | ||
@@ -77,5 +76,5 @@ }); | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createActual({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'span', attribs: { className: 'bar' }, children: ['some text'] }, | ||
createExpected({ name: 'span', attribs: { className: 'bar' }, children: ['some text'] }), | ||
'to satisfy', | ||
@@ -96,3 +95,4 @@ { | ||
weight: Diff.DefaultWeights.ATTRIBUTE_MISMATCH | ||
}); | ||
} | ||
); | ||
}); | ||
@@ -103,19 +103,22 @@ | ||
return expect({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
return expect( | ||
createActual({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'span', attribs: {}, children: ['some text'] }, | ||
'to satisfy', { | ||
diff: { | ||
attributes: [ | ||
{ | ||
name: 'className', | ||
value: 'foo', | ||
diff: { | ||
type: 'extra' | ||
createExpected({ name: 'span', attribs: {}, children: ['some text'] }), | ||
'to satisfy', | ||
{ | ||
diff: { | ||
attributes: [ | ||
{ | ||
name: 'className', | ||
value: 'foo', | ||
diff: { | ||
type: 'extra' | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.ATTRIBUTE_EXTRA | ||
}); | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.ATTRIBUTE_EXTRA | ||
} | ||
); | ||
}); | ||
@@ -125,6 +128,5 @@ | ||
return expect({ name: 'span', attribs: { id: 'abc', className: 'foo' }, children: ['some text'] }, | ||
'when diffed against', | ||
{ name: 'span', attribs: { id: 'abcd' }, children: ['some text'] }, | ||
'to satisfy', { | ||
return expect(createActual( | ||
{ name: 'span', attribs: { id: 'abc', className: 'foo' }, children: ['some text'] } | ||
), 'when diffed against', createExpected({ name: 'span', attribs: { id: 'abcd' }, children: ['some text'] }), 'to satisfy', { | ||
diff: { | ||
@@ -155,19 +157,22 @@ attributes: [ | ||
return expect({ name: 'span', attribs: {}, children: ['some text'] }, | ||
return expect( | ||
createActual({ name: 'span', attribs: {}, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
'to satisfy', { | ||
diff: { | ||
attributes: [ | ||
{ | ||
name: 'className', | ||
diff: { | ||
type: 'missing', | ||
expectedValue: 'foo' | ||
createExpected({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'to satisfy', | ||
{ | ||
diff: { | ||
attributes: [ | ||
{ | ||
name: 'className', | ||
diff: { | ||
type: 'missing', | ||
expectedValue: 'foo' | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.ATTRIBUTE_MISSING | ||
}); | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.ATTRIBUTE_MISSING | ||
} | ||
); | ||
}); | ||
@@ -177,34 +182,6 @@ | ||
return expect({ name: 'span', attribs: {}, children: ['some text'] }, | ||
return expect( | ||
createActual({ name: 'span', attribs: {}, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'span', attribs: {}, children: ['some changed text'] }, | ||
'to satisfy', { | ||
diff: { | ||
children: [ | ||
{ | ||
type: 'CONTENT', | ||
value: 'some text', | ||
diff: { | ||
type: 'changed', | ||
expectedValue: 'some changed text' | ||
} | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.STRING_CONTENT_MISMATCH | ||
}); | ||
}); | ||
it('diffs a removed last child', () => { | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] } | ||
] }, | ||
'when diffed against', | ||
{ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, | ||
createExpected({ name: 'span', attribs: {}, children: ['some changed text'] }), | ||
'to satisfy', | ||
@@ -215,36 +192,63 @@ { | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child1' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child2' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
type: 'CONTENT', | ||
value: 'some text', | ||
diff: { | ||
type: 'missing' | ||
}, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child3' | ||
}] | ||
type: 'changed', | ||
expectedValue: 'some changed text' | ||
} | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.CHILD_MISSING | ||
}); | ||
weight: Diff.DefaultWeights.STRING_CONTENT_MISMATCH | ||
} | ||
); | ||
}); | ||
it('diffs a removed last child', () => { | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] } | ||
] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }), 'to satisfy', { | ||
diff: { | ||
children: [ | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child1' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child2' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
diff: { | ||
type: 'missing' | ||
}, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child3' | ||
}] | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.CHILD_MISSING | ||
}); | ||
}); | ||
it('diffs a removed middle child', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'span', attribs: {}, children: [ | ||
@@ -254,47 +258,43 @@ { name: 'child', attribs: {}, children: ['child1'] }, | ||
] | ||
}), 'when diffed against', createExpected({ | ||
name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] | ||
}), 'to satisfy', { | ||
diff: { | ||
children: [ | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child1' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
diff: { | ||
type: 'missing', | ||
}, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child2' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
diff: undefined, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child3' | ||
}] | ||
} | ||
] | ||
}, | ||
'when diffed against', | ||
{ | ||
name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] | ||
}, | ||
'to satisfy', | ||
{ | ||
diff: { | ||
children: [ | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child1' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
diff: { | ||
type: 'missing', | ||
}, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child2' | ||
}] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'child', | ||
diff: undefined, | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'child3' | ||
}] | ||
} | ||
] | ||
}, | ||
weight: Diff.DefaultWeights.CHILD_MISSING | ||
}); | ||
weight: Diff.DefaultWeights.CHILD_MISSING | ||
}); | ||
@@ -307,10 +307,10 @@ | ||
it('diffs an extra last child', () => { | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'when diffed against', { name: 'span', attribs: {}, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -353,10 +353,10 @@ children: [ | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'when diffed against', { name: 'span', attribs: {}, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -399,11 +399,11 @@ children: [ | ||
it('diffs a changed middle child', () => { | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2 changed'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'when diffed against', { name: 'span', attribs: {}, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -446,7 +446,49 @@ children: [ | ||
it('diffs an out of order element', () => { | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'Test', attribs: {}, children: ['one'] }, | ||
{ name: 'Test', attribs: {}, children: ['two'] }, | ||
{ name: 'Test', attribs: {}, children: ['three'] } | ||
] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'Test', attribs: {}, children: ['one'] }, | ||
{ name: 'Test', attribs: {}, children: ['three'] }, | ||
{ name: 'Test', attribs: {}, children: ['two'] } | ||
] }), 'to satisfy', { | ||
diff: { | ||
children: [ | ||
{ | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [ { type: 'CONTENT', value: 'one' } ] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [ { type: 'CONTENT', value: 'three' } ], | ||
diff: { type: 'missing', actualIndex: 2 } | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [ { type: 'CONTENT', value: 'two' } ] | ||
}, | ||
{ | ||
type: 'ELEMENT', | ||
name: 'Test', | ||
children: [ { type: 'CONTENT', value: 'three' } ], | ||
diff: { type: 'extra' } | ||
} | ||
] | ||
} | ||
}); | ||
}); | ||
it('diffs a missing content entry', () => { | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child3'] }, 'when diffed against', { name: 'span', attribs: {}, children: [ | ||
'child1', 'child2', 'child3'] }, 'to satisfy', { | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child3'] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child2', 'child3'] }), 'to satisfy', { | ||
diff: { | ||
@@ -477,5 +519,5 @@ children: [ | ||
// See comments in 'diffs a removed middle child' as to why this isn't an ideal diff | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child2', 'child3'] }, 'when diffed against', { name: 'span', attribs: {}, children: [ | ||
'child1', 'child3'] }, 'to satisfy', { | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child2', 'child3'] }), 'when diffed against', createExpected({ name: 'span', attribs: {}, children: [ | ||
'child1', 'child3'] }), 'to satisfy', { | ||
diff: { | ||
@@ -506,5 +548,5 @@ children: [ | ||
return expect( | ||
{ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createActual({ name: 'span', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'when diffed against', | ||
{ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createExpected({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'to satisfy', | ||
@@ -533,3 +575,3 @@ { | ||
'when diffed against', | ||
{ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createExpected({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'to satisfy', | ||
@@ -559,3 +601,3 @@ { | ||
return expect( | ||
{ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }, | ||
createActual({ name: 'div', attribs: { className: 'foo' }, children: ['some text'] }), | ||
'when diffed with options against', | ||
@@ -591,9 +633,9 @@ { | ||
it('diffs a wrapper around a single child', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] } | ||
] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -625,9 +667,9 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around a single child', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] } | ||
] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -659,3 +701,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around multiple children', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [ | ||
@@ -666,7 +708,7 @@ { name: 'real', attribs: { className: 'real-element-1' } }, | ||
] } | ||
] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element-1' } }, | ||
{ name: 'real', attribs: { className: 'real-element-2' } }, | ||
{ name: 'real', attribs: { className: 'real-element-3' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -696,3 +738,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around each of several children', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [ | ||
@@ -710,7 +752,7 @@ { name: 'real', attribs: { className: 'real-element-1' } } | ||
} | ||
] }, 'when diffed against', { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed against', createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element-1' } }, | ||
{ name: 'real', attribs: { className: 'real-element-2' } }, | ||
{ name: 'real', attribs: { className: 'real-element-3' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -761,11 +803,11 @@ type: 'ELEMENT', | ||
it('diffs a simple wrapper with diffWrappers:false', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] } | ||
] }, 'when diffed with options against', { | ||
] }), 'when diffed with options against', { | ||
diffWrappers: false | ||
}, { name: 'div', attribs: { className: 'foo' }, children: [ | ||
}, createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -795,3 +837,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around multiple children with diffWrappers:false', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper' }, children: [ | ||
@@ -802,7 +844,7 @@ { name: 'real', attribs: { className: 'real-element-1' } }, | ||
] } | ||
] }, 'when diffed with options against', { diffWrappers: false }, { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed with options against', { diffWrappers: false }, createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element-1' } }, | ||
{ name: 'real', attribs: { className: 'real-element-2' } }, | ||
{ name: 'real', attribs: { className: 'real-element-3' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -841,3 +883,3 @@ type: 'ELEMENT', | ||
it('diffs a wrapper around each of several children with diffWrappers:false', () => { | ||
return expect({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
return expect(createActual({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'wrapper', attribs: { className: 'the-wrapper-1' }, children: [ | ||
@@ -855,7 +897,7 @@ { name: 'real', attribs: { className: 'real-element-1' } } | ||
} | ||
] }, 'when diffed with options against', { diffWrappers: false }, { name: 'div', attribs: { className: 'foo' }, children: [ | ||
] }), 'when diffed with options against', { diffWrappers: false }, createExpected({ name: 'div', attribs: { className: 'foo' }, children: [ | ||
{ name: 'real', attribs: { className: 'real-element-1' } }, | ||
{ name: 'real', attribs: { className: 'real-element-2' } }, | ||
{ name: 'real', attribs: { className: 'real-element-3' } } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -909,3 +951,3 @@ type: 'ELEMENT', | ||
it('ignores a top level wrapper with diffWrappers:false', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'TopLevel', attribs: {}, children: [ | ||
@@ -917,3 +959,3 @@ { name: 'MidLevel', attribs: {}, children: [ | ||
] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, createExpected({ | ||
name: 'MidLevel', attribs: {}, children: [ | ||
@@ -923,3 +965,3 @@ { name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -941,3 +983,3 @@ type: 'WRAPPERELEMENT', | ||
it('ignores two levels of wrapper with diffWrappers:false', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'HigherOrderTopLevel', attribs: { id: 'main' }, children: [ | ||
@@ -953,3 +995,3 @@ { | ||
] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, createExpected({ | ||
name: 'MidLevel', attribs: {}, children: [ | ||
@@ -959,3 +1001,3 @@ { name: 'span', attribs: { id: 'childfoo' }, children: ['one'] }, | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -985,10 +1027,10 @@ type: 'WRAPPERELEMENT', | ||
it('ignores missing children if diffMissingChildren:false', () => { | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] } | ||
] }, 'when diffed with options against', { diffMissingChildren: false }, { name: 'span', attribs: {}, children: [ | ||
] }), 'when diffed with options against', { diffMissingChildren: false }, createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -1002,10 +1044,10 @@ children: expect.it('to have length', 2) | ||
it('ignores extra children if diffExtraChildren:false', () => { | ||
return expect({ name: 'span', attribs: {}, children: [ | ||
return expect(createActual({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] }, | ||
{ name: 'child', attribs: {}, children: ['child3'] } | ||
] }, 'when diffed with options against', { diffExtraChildren: false }, { name: 'span', attribs: {}, children: [ | ||
] }), 'when diffed with options against', { diffExtraChildren: false }, createExpected({ name: 'span', attribs: {}, children: [ | ||
{ name: 'child', attribs: {}, children: ['child1'] }, | ||
{ name: 'child', attribs: {}, children: ['child2'] } | ||
] }, 'to satisfy', { | ||
] }), 'to satisfy', { | ||
diff: { | ||
@@ -1031,3 +1073,3 @@ children: [ | ||
it('ignores missing attributes if diffRemovedAttributes:false', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'span', | ||
@@ -1038,3 +1080,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffRemovedAttributes: false }, { | ||
}), 'when diffed with options against', { diffRemovedAttributes: false }, createExpected({ | ||
name: 'span', | ||
@@ -1046,3 +1088,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1058,3 +1100,3 @@ type: 'ELEMENT', | ||
it('ignores extra attributes if diffExtraAttributes:false', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'span', | ||
@@ -1066,3 +1108,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: false }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: false }, createExpected({ | ||
name: 'span', | ||
@@ -1073,3 +1115,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1088,3 +1130,3 @@ type: 'ELEMENT', | ||
it('treats undefined attributes as not defined', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'span', | ||
@@ -1096,3 +1138,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: true }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: true }, createExpected({ | ||
name: 'span', | ||
@@ -1103,3 +1145,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1119,3 +1161,3 @@ type: 'ELEMENT', | ||
it('treats null attributes as defined', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'span', | ||
@@ -1127,3 +1169,3 @@ attribs: { | ||
children: [] | ||
}, 'when diffed with options against', { diffExtraAttributes: true }, { | ||
}), 'when diffed with options against', { diffExtraAttributes: true }, createExpected({ | ||
name: 'span', | ||
@@ -1134,3 +1176,3 @@ attribs: { | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1149,3 +1191,3 @@ type: 'ELEMENT', | ||
it("doesn't wrap an element when it means there are missing children", () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'SomeElement', | ||
@@ -1156,3 +1198,3 @@ attribs: {}, | ||
] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, createExpected({ | ||
name: 'SomeElement', | ||
@@ -1163,3 +1205,3 @@ attribs: {}, | ||
] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1186,3 +1228,3 @@ type: 'ELEMENT', | ||
it('diffs extra children when the expected has no children but wrappers are allowed', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
name: 'SomeElement', | ||
@@ -1193,7 +1235,7 @@ attribs: {}, | ||
] | ||
}, 'when diffed with options against', { diffWrappers: false }, { | ||
}), 'when diffed with options against', { diffWrappers: false }, createExpected({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1218,3 +1260,3 @@ type: 'ELEMENT', | ||
it('accepts a passing expect.it attribute assertion', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1225,3 +1267,3 @@ name: 'SomeElement', | ||
} | ||
}, 'when diffed against', { | ||
}), 'when diffed against', createExpected({ | ||
name: 'SomeElement', | ||
@@ -1231,3 +1273,3 @@ attribs: { | ||
} | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1246,3 +1288,3 @@ type: 'ELEMENT', | ||
it('diffs an expect.it attribute assertion', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1253,3 +1295,3 @@ name: 'SomeElement', | ||
} | ||
}, 'when diffed against', { | ||
}), 'when diffed against', createExpected({ | ||
name: 'SomeElement', | ||
@@ -1259,3 +1301,3 @@ attribs: { | ||
} | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1278,3 +1320,3 @@ type: 'ELEMENT', | ||
it('diffs an expect.it content assertion', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1284,7 +1326,7 @@ name: 'SomeElement', | ||
children: [ 'abcde' ] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', createExpected({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [expect.it('to match', /[a-d]+$/) ] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1309,3 +1351,3 @@ type: 'ELEMENT', | ||
it('returns a CONTENT type for a passed content assertion', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1315,7 +1357,7 @@ name: 'SomeElement', | ||
children: [ 'abcd' ] | ||
}, 'when diffed against', { | ||
}), 'when diffed against', createExpected({ | ||
name: 'SomeElement', | ||
attribs: {}, | ||
children: [expect.it('to match', /[a-d]+$/) ] | ||
}, 'to satisfy', { | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1339,3 +1381,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1345,10 +1387,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: true }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'one two three' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: true }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'one two three' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1373,3 +1413,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1379,10 +1419,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'one two three' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'one two three' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1404,3 +1442,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1410,10 +1448,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1438,3 +1474,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1444,10 +1480,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1472,3 +1506,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1478,10 +1512,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1507,3 +1539,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1513,10 +1545,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1543,3 +1573,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1549,10 +1579,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'foob' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'foob' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1579,3 +1607,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1585,10 +1613,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1610,3 +1636,3 @@ type: 'ELEMENT', | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1616,10 +1642,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'xtra two' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffExtraClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'xtra two' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1640,7 +1664,7 @@ type: 'ELEMENT', | ||
}) | ||
}); | ||
it('ignores a missing class when diffMissingClasses is false', () => { | ||
return expect({ | ||
return expect(createActual({ | ||
type: 'ELEMENT', | ||
@@ -1650,10 +1674,8 @@ name:'SomeElement', | ||
children: [] | ||
}, 'when diffed with options against', { diffExactClasses: false, diffMissingClasses: false }, | ||
{ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}, | ||
'to satisfy', { | ||
}), 'when diffed with options against', { diffExactClasses: false, diffMissingClasses: false }, createExpected({ | ||
type: 'ELEMENT', | ||
name:'SomeElement', | ||
attribs: { className: 'three two one' }, | ||
children: [] | ||
}), 'to satisfy', { | ||
diff: { | ||
@@ -1660,0 +1682,0 @@ type: 'ELEMENT', |
@@ -1213,2 +1213,47 @@ | ||
it('outputs a moved element hint', () => { | ||
/* | ||
* This is where the actual is | ||
* <span> | ||
* <Test>one</Test> | ||
* <Test>three</Test> | ||
* <Test>two</Test> | ||
* </span> | ||
* | ||
* And should be one, two, three. | ||
*/ | ||
Painter(pen, { | ||
type: 'ELEMENT', | ||
name: 'span', | ||
attributes: [], | ||
children: [ | ||
{ type: 'ELEMENT', name: 'Test', attributes: [], children: [ { type: 'CONTENT', value: 'one' } ] }, | ||
{ | ||
type: 'ELEMENT', name: 'Test', attributes: [], children: [ { type: 'CONTENT', value: 'two' } ], | ||
diff: { | ||
type: 'missing', | ||
actualIndex: 2 | ||
} | ||
}, | ||
{ type: 'ELEMENT', name: 'Test', attributes: [], children: [ { type: 'CONTENT', value: 'three' } ] }, | ||
{ | ||
type: 'ELEMENT', name: 'Test', attributes: [], children: [ { type: 'CONTENT', value: 'two' } ], | ||
diff: { | ||
type: 'extra' | ||
} | ||
} | ||
] | ||
}); | ||
expect(pen.toString(), 'to equal', | ||
'<span>\n' + | ||
' <Test>one</Test>\n' + | ||
' // missing (found at index 2) <Test>two</Test>\n' + | ||
' <Test>three</Test>\n' + | ||
' <Test>two</Test> // should be removed\n' + | ||
'</span>'); | ||
}); | ||
describe('class differences', () => { | ||
@@ -1215,0 +1260,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1154407
80
10671