Skip to content

Commit

Permalink
fix: apply fix line endings to code and output in two spots (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Apr 10, 2020
1 parent 70bc21b commit f1c17ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugin-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function pluginTester({
} else {
assert.equal(
result.trim(),
code.trim(),
fixLineEndings(code, endOfLine),
'Expected output to not change, but it did',
)
}
Expand Down Expand Up @@ -224,8 +224,8 @@ function pluginTester({
}
}

function fixLineEndings(code, endOfLine, input) {
return code.replace(/\r?\n/g, getReplacement())
function fixLineEndings(string, endOfLine, input = string) {
return String(string).replace(/\r?\n/g, getReplacement()).trim()

function getReplacement() {
switch (endOfLine) {
Expand Down Expand Up @@ -356,7 +356,7 @@ const createFixtureTests = (fixturesDir, options) => {

assert.equal(
actual.trim(),
output.trim(),
fixLineEndings(output, endOfLine),
`actual output does not match ${fixtureOutputName}${ext}`,
)
})
Expand Down

0 comments on commit f1c17ef

Please sign in to comment.