Skip to content

Commit b000781

Browse files
committed
Don't trim strings in readFromFixture
1 parent dc8577a commit b000781

File tree

8 files changed

+19
-13
lines changed

8 files changed

+19
-13
lines changed

src/oneLine/oneLine.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { readFromFixture } from '../testUtils';
44
const val = 'amaze';
55

66
test('reduces text to one line, replacing newlines with spaces', () => {
7-
const expected = readFromFixture(__dirname, 'oneLine');
7+
const expected = readFromFixture(__dirname, 'oneLine').trim();
88
const actual = oneLine`
99
wow such doge
1010
is very ${val}
@@ -15,7 +15,7 @@ test('reduces text to one line, replacing newlines with spaces', () => {
1515
});
1616

1717
test('reduces text to one line, replacing newlines with spaces (no indentation)', () => {
18-
const expected = readFromFixture(__dirname, 'oneLine');
18+
const expected = readFromFixture(__dirname, 'oneLine').trim();
1919
const actual = oneLine`
2020
wow such doge
2121
is very ${val}
@@ -27,7 +27,7 @@ from multiline
2727
});
2828

2929
test('preserves whitespace within input lines, replacing only newlines', () => {
30-
const expected = readFromFixture(__dirname, 'oneLine-sentence');
30+
const expected = readFromFixture(__dirname, 'oneLine-sentence').trim();
3131
const actual = oneLine`
3232
Sentences also work. Double
3333
spacing is preserved.

src/oneLineCommaLists/oneLineCommaLists.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const val = 'amaze';
55

66
test('includes arrays as comma-separated list on one line', () => {
77
const fruits = ['apple', 'banana', 'kiwi'];
8-
const expected = readFromFixture(__dirname, 'oneLineCommaLists');
8+
const expected = readFromFixture(__dirname, 'oneLineCommaLists').trim();
99
const actual = oneLineCommaLists`
1010
Doge <3's these fruits: ${fruits}
1111
they are ${val}

src/oneLineCommaListsAnd/oneLineCommaListsAnd.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const val = 'amaze';
55

66
test('includes arrays as comma-separated list on one line with "and"', () => {
77
const fruits = ['apple', 'banana', 'kiwi'];
8-
const expected = readFromFixture(__dirname, 'oneLineCommaListsAnd');
8+
const expected = readFromFixture(__dirname, 'oneLineCommaListsAnd').trim();
99
const actual = oneLineCommaListsAnd`
1010
Doge <3's these fruits: ${fruits}
1111
they are ${val}
@@ -15,7 +15,10 @@ test('includes arrays as comma-separated list on one line with "and"', () => {
1515

1616
test('only returns the first item of a single element array', () => {
1717
const fruits = ['apple'];
18-
const expected = readFromFixture(__dirname, 'oneLineCommaListsAndSingleItem');
18+
const expected = readFromFixture(
19+
__dirname,
20+
'oneLineCommaListsAndSingleItem',
21+
).trim();
1922
const actual = oneLineCommaListsAnd`
2023
Doge <3's these fruits: ${fruits}
2124
they are ${val}

src/oneLineCommaListsOr/oneLineCommaListsOr.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const val = 'amaze';
55

66
test('includes arrays as comma-separated list on one line with "or"', () => {
77
const fruits = ['apple', 'banana', 'kiwi'];
8-
const expected = readFromFixture(__dirname, 'oneLineCommaListsOr');
8+
const expected = readFromFixture(__dirname, 'oneLineCommaListsOr').trim();
99
const actual = oneLineCommaListsOr`
1010
Doge <3's these fruits: ${fruits}
1111
they are ${val}
@@ -15,7 +15,10 @@ test('includes arrays as comma-separated list on one line with "or"', () => {
1515

1616
test('only returns the first item of a single element array', () => {
1717
const fruits = ['apple'];
18-
const expected = readFromFixture(__dirname, 'oneLineCommaListsOrSingleItem');
18+
const expected = readFromFixture(
19+
__dirname,
20+
'oneLineCommaListsOrSingleItem',
21+
).trim();
1922
const actual = oneLineCommaListsOr`
2023
Doge <3's these fruits: ${fruits}
2124
they are ${val}

src/oneLineInlineLists/oneLineInlineLists.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const val = 'amaze';
55

66
test('includes arrays as inline list on one line', () => {
77
const fruits = ['apple', 'banana', 'kiwi'];
8-
const expected = readFromFixture(__dirname, 'oneLineInlineLists');
8+
const expected = readFromFixture(__dirname, 'oneLineInlineLists').trim();
99
const actual = oneLineInlineLists`
1010
Doge <3's these fruits: ${fruits}
1111
they are ${val}

src/oneLineTrim/oneLineTrim.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { readFromFixture } from '../testUtils';
44
const val = 'amaze';
55

66
test('reduces to one line while trimming newlines', () => {
7-
const expected = readFromFixture(__dirname, 'oneLineTrim');
7+
const expected = readFromFixture(__dirname, 'oneLineTrim').trim();
88
const actual = oneLineTrim`
99
wow such reduction
1010
very absence of space
@@ -14,7 +14,7 @@ test('reduces to one line while trimming newlines', () => {
1414
});
1515

1616
test('reduces to one line while trimming newlines (no indentation)', () => {
17-
const expected = readFromFixture(__dirname, 'oneLineTrim');
17+
const expected = readFromFixture(__dirname, 'oneLineTrim').trim();
1818
const actual = oneLineTrim`
1919
wow such reduction
2020
very absence of space

src/testUtils/readFromFixture/readFromFixture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export default function readFromFixture(dirname, name) {
1212
path.join(dirname, `fixtures/${name}.txt`),
1313
'utf8',
1414
);
15-
return contents.replace(/\r\n/g, '\n').trim();
15+
return contents.replace(/\r\n/g, '\n');
1616
}

src/testUtils/readFromFixture/readFromFixture.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import readFromFixture from './readFromFixture';
22

33
test('reads the correct fixture contents', () => {
44
const actual = readFromFixture(__dirname, 'contents');
5-
const expected = 'wow such doge';
5+
const expected = 'wow such doge\n';
66
expect(actual).toBe(expected);
77
});
88

0 commit comments

Comments
 (0)