@createiq/htmldiff 1.1.0-beta.0 → 1.2.0-beta.0
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/README.md +40 -0
- package/dist/HtmlDiff.cjs +1259 -498
- package/dist/HtmlDiff.cjs.map +1 -1
- package/dist/HtmlDiff.d.cts +141 -7
- package/dist/HtmlDiff.d.mts +140 -7
- package/dist/HtmlDiff.mjs +1259 -498
- package/dist/HtmlDiff.mjs.map +1 -1
- package/package.json +7 -7
- package/src/Alignment.ts +349 -0
- package/src/HtmlDiff.ts +323 -33
- package/src/HtmlScanner.ts +200 -0
- package/src/TableDiff.ts +99 -550
- package/src/ThreeWayDiff.ts +223 -0
- package/src/ThreeWayTable.ts +701 -0
- package/src/Utils.ts +34 -2
- package/test/HtmlDiff.analyze.spec.ts +152 -0
- package/test/HtmlDiff.tables.matrix.spec.ts +8 -3
- package/test/HtmlDiff.tables.spec.ts +368 -19
- package/test/HtmlDiff.threeWay.spec.ts +175 -0
- package/test/HtmlDiff.threeWay.tables.spec.ts +407 -0
- package/test/TableDiff.bench.ts +39 -0
- package/test/Utils.spec.ts +48 -0
package/test/Utils.spec.ts
CHANGED
|
@@ -117,4 +117,52 @@ describe('Utils', () => {
|
|
|
117
117
|
expect(Utils.isWord('b')).toBe(true)
|
|
118
118
|
})
|
|
119
119
|
})
|
|
120
|
+
|
|
121
|
+
describe('wrapText()', () => {
|
|
122
|
+
it('produces the historical shape when no metadata is passed', () => {
|
|
123
|
+
expect(Utils.wrapText('hello', 'ins', 'diffins')).toBe("<ins class='diffins'>hello</ins>")
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('appends extraClasses after the base class', () => {
|
|
127
|
+
expect(Utils.wrapText('hello', 'ins', 'diffins', { extraClasses: 'cp' })).toBe(
|
|
128
|
+
"<ins class='diffins cp'>hello</ins>"
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('emits data-* attributes for each entry in dataAttrs', () => {
|
|
133
|
+
expect(Utils.wrapText('hello', 'ins', 'diffins', { dataAttrs: { author: 'cp' } })).toBe(
|
|
134
|
+
"<ins class='diffins' data-author='cp'>hello</ins>"
|
|
135
|
+
)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('combines extraClasses and dataAttrs in one call', () => {
|
|
139
|
+
expect(
|
|
140
|
+
Utils.wrapText('hello', 'del', 'diffdel', {
|
|
141
|
+
extraClasses: 'me rejects-cp',
|
|
142
|
+
dataAttrs: { author: 'me', rejects: 'cp' },
|
|
143
|
+
})
|
|
144
|
+
).toBe("<del class='diffdel me rejects-cp' data-author='me' data-rejects='cp'>hello</del>")
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('skips the metadata path entirely when neither extraClasses nor dataAttrs is set', () => {
|
|
148
|
+
// Empty metadata should still pass through the chosen branch deterministically.
|
|
149
|
+
expect(Utils.wrapText('hello', 'ins', 'diffins', {})).toBe("<ins class='diffins'>hello</ins>")
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
describe('composeTagAttributes()', () => {
|
|
154
|
+
it('returns just the class attribute when metadata is empty', () => {
|
|
155
|
+
expect(Utils.composeTagAttributes('diffins', {})).toBe(" class='diffins'")
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('appends extraClasses inside the class attribute', () => {
|
|
159
|
+
expect(Utils.composeTagAttributes('mod strong', { extraClasses: 'cp' })).toBe(" class='mod strong cp'")
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('includes all data-* attrs after the class attr', () => {
|
|
163
|
+
expect(Utils.composeTagAttributes('mod', { dataAttrs: { author: 'me', flag: 'on' } })).toBe(
|
|
164
|
+
" class='mod' data-author='me' data-flag='on'"
|
|
165
|
+
)
|
|
166
|
+
})
|
|
167
|
+
})
|
|
120
168
|
})
|