Skip to content

Commit c269f86

Browse files
committed
Fix b annotation
1 parent e1af38a commit c269f86

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

__tests__/__snapshots__/snapshotDiff.test.js.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`can colorize diff 1`] = `
4-
"[32m- Second value[39m
5-
[31m+ Received[39m
4+
"[32m- First value[39m
5+
[31m+ Second value[39m
66
77
 
88
   some
@@ -20,8 +20,8 @@ exports[`can colorize diff 1`] = `
2020
`;
2121

2222
exports[`can expand diff 1`] = `
23-
"- Second value
24-
+ Received
23+
"- First value
24+
+ Second value
2525
2626
2727
some
@@ -39,8 +39,8 @@ exports[`can expand diff 1`] = `
3939
`;
4040

4141
exports[`collapses diffs and strips ansi by default 1`] = `
42-
"- Second value
43-
+ Received
42+
"- First value
43+
+ Second value
4444
4545
@@ -5,8 +5,9 @@
4646
some
@@ -89,3 +89,13 @@ exports[`detects React components 1`] = `
8989
<span />
9090
<span />"
9191
`;
92+
93+
exports[`diffs short strings 1`] = `
94+
"- First value
95+
+ Second value
96+
97+
98+
- abcx
99+
+ abcy
100+
"
101+
`;

__tests__/snapshotDiff.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ test('can colorize diff', () => {
128128
expect(snapshotDiff(a, b, {colors: true})).toMatchSnapshot();
129129
});
130130

131+
test('diffs short strings', () => {
132+
const x = `
133+
abcx
134+
`;
135+
const y = `
136+
abcy
137+
`;
138+
expect(snapshotDiff(x, y)).toMatchSnapshot();
139+
});
140+
131141
test('detects React components', () => {
132142
expect(
133143
snapshotDiff(<Component test="say" />, <Component test="my name" />)

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const snapshotDiff = (
2020
valueA: any,
2121
valueB: any,
2222
options?: Options = defaultOptions
23-
) => {
23+
): string => {
2424
let difference;
2525

2626
if (isReactComponent(valueA) && isReactComponent(valueB)) {
@@ -43,7 +43,7 @@ function diffStrings(valueA, valueB, options) {
4343
return diff(valueA, valueB, {
4444
expand: options.expand,
4545
aAnnotation: 'First value',
46-
aAnnotation: 'Second value'
46+
bAnnotation: 'Second value'
4747
});
4848
}
4949

0 commit comments

Comments
 (0)