@createiq/htmldiff 1.0.5-beta.1 → 1.0.5-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HtmlDiff.cjs +171 -11
- package/dist/HtmlDiff.cjs.map +1 -1
- package/dist/HtmlDiff.mjs +171 -11
- package/dist/HtmlDiff.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TableDiff.ts +258 -26
- package/test/HtmlDiff.tables.matrix.spec.ts +327 -0
- package/test/HtmlDiff.tables.spec.ts +39 -0
|
@@ -1268,6 +1268,45 @@ describe('HtmlDiff — tables', () => {
|
|
|
1268
1268
|
)
|
|
1269
1269
|
})
|
|
1270
1270
|
|
|
1271
|
+
it('handles column-add alongside content edit in the SAME row (cell-level fuzzy matching)', () => {
|
|
1272
|
+
// Real-world scenario: a column was inserted at position 1 AND
|
|
1273
|
+
// one of the existing cells got new content appended. Without
|
|
1274
|
+
// cell-level fuzzy matching, the cell-LCS exact-match misses the
|
|
1275
|
+
// "IRS Forms…" pairing, producing a 5-cell row (phantom delete +
|
|
1276
|
+
// two inserts) instead of 4 cells with one inline content edit.
|
|
1277
|
+
const oldHtml =
|
|
1278
|
+
'<table>' +
|
|
1279
|
+
'<tr><th>Party</th><th>Form</th><th>Date</th></tr>' +
|
|
1280
|
+
'<tr><td>Party A</td><td>IRS Forms W-8BEN-E and W-8ECI (or any successors thereto).</td><td>Upon execution.</td></tr>' +
|
|
1281
|
+
'<tr><td>Party B</td><td>IRS Form W-9, as applicable.</td><td>Upon execution.</td></tr>' +
|
|
1282
|
+
'</table>'
|
|
1283
|
+
const newHtml =
|
|
1284
|
+
'<table>' +
|
|
1285
|
+
'<tr><th>Party</th><th>Extra column</th><th>Form</th><th>Date</th></tr>' +
|
|
1286
|
+
"<tr><td>Party A</td><td>Yes</td><td>IRS Forms W-8BEN-E and W-8ECI (or any successors thereto). Here's some extra content</td><td>Upon execution.</td></tr>" +
|
|
1287
|
+
'<tr><td>Party B</td><td>A</td><td>IRS Form W-9, as applicable.</td><td>Upon execution.</td></tr>' +
|
|
1288
|
+
'</table>'
|
|
1289
|
+
|
|
1290
|
+
expect(HtmlDiff.execute(oldHtml, newHtml)).toEqual(
|
|
1291
|
+
'<table>' +
|
|
1292
|
+
// Header row: extra column inserted at position 1
|
|
1293
|
+
'<tr><th>Party</th>' +
|
|
1294
|
+
"<th class='diffins'><ins class='diffins'>Extra column</ins></th>" +
|
|
1295
|
+
'<th>Form</th><th>Date</th></tr>' +
|
|
1296
|
+
// Party A row: extra column cell + content edit on the IRS Forms cell
|
|
1297
|
+
'<tr><td>Party A</td>' +
|
|
1298
|
+
"<td class='diffins'><ins class='diffins'>Yes</ins></td>" +
|
|
1299
|
+
"<td>IRS Forms W-8BEN-E and W-8ECI (or any successors thereto).<ins class='diffins'> Here's some extra content</ins></td>" +
|
|
1300
|
+
'<td>Upon execution.</td></tr>' +
|
|
1301
|
+
// Party B row: extra column cell, IRS Form W-9 cell unchanged
|
|
1302
|
+
'<tr><td>Party B</td>' +
|
|
1303
|
+
"<td class='diffins'><ins class='diffins'>A</ins></td>" +
|
|
1304
|
+
'<td>IRS Form W-9, as applicable.</td>' +
|
|
1305
|
+
'<td>Upon execution.</td></tr>' +
|
|
1306
|
+
'</table>'
|
|
1307
|
+
)
|
|
1308
|
+
})
|
|
1309
|
+
|
|
1271
1310
|
it('handles a rowspan cell sharing a row with normal cells (column-add adjacency)', () => {
|
|
1272
1311
|
// The rowspan'd cell occupies row 0 col 0 and row 1's col 0 slot
|
|
1273
1312
|
// (absorbed). Old has rowspan=2 in col 0 + col 1 in row 0 + col
|