Skip to content

Commit 7872957

Browse files
committed
fix diffing for strings
1 parent 656add5 commit 7872957

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

diff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function diffStat(statA, statB, key) {
3737
return diffLists(statA, statB, key)
3838
}
3939

40-
if (typeof statA === 'string') {
40+
if (typeof statB === 'string') {
4141
return diffStrings(statA, statB)
4242
}
4343

test/diff.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ test('It should return the correct structure when new props are added', t => {
3434
const result = diff(defaultFixture, fixtureWithAddedProp)
3535
t.deepEqual(['a', 'b', 'c'], Object.keys(result))
3636
})
37+
38+
test('It should diff strings correctly after they are introduced in css-analyzer v2.0.0', t => {
39+
t.deepEqual(diff({}, {'selectors.identifiers.max.value': '.my-selector'}), {
40+
'selectors.identifiers.max.value': {
41+
changed: true,
42+
oldValue: null,
43+
newValue: '.my-selector'
44+
}
45+
})
46+
})

0 commit comments

Comments
 (0)