Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join lines with newline in jest-diff #4314

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
Object {
\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 6,
Expand Down Expand Up @@ -178,7 +178,7 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
Object {
\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 7,
Expand Down Expand Up @@ -247,7 +247,7 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
Object {
- \\"a\\": 2,
+ \\"a\\": 1,
}
Expand Down
14 changes: 6 additions & 8 deletions packages/jest-diff/src/diff_strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ const diffLines = (a: string, b: string): Diff => {
.map(line => {
const highlightedLine = highlightTrailingWhitespace(line, bgColor);
const mark = color(part.added ? '+' : part.removed ? '-' : ' ');
return mark + ' ' + color(highlightedLine) + '\n';
return mark + ' ' + color(highlightedLine);
})
.join('');
.join('\n');
})
.join('')
.trim(),
.join('\n'),
isDifferent,
};
};
Expand Down Expand Up @@ -125,17 +124,16 @@ const structuredPatch = (a: string, b: string, contextLines?: number): Diff => {
const bgColor = getBgColor(added, removed);

const highlightedLine = highlightTrailingWhitespace(line, bgColor);
return color(highlightedLine) + '\n';
return color(highlightedLine);
})
.join('');
.join('\n');

isDifferent = true;
return shouldShowPatchMarks(hunk, oldLinesCount)
? createPatchMark(hunk) + lines
: lines;
})
.join('')
.trim(),
.join('\n'),
isDifferent,
};
};
Expand Down