Skip to content

Commit

Permalink
ensures line folding is working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed May 26, 2024
1 parent 414efed commit 3f65da7
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions test/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,17 @@ X-Poedit-SourceCharset: UTF-8`;
expect(folded.length).to.equal(3);
});

it('should ensure that the line never ends with a partial escaping', () => {
const line = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\'aaaaa\'aaaa';
it('should fold the line into multiple lines with the right length', () => {
const line = Array.from({ length: 75 }, () => 'a').join('') + '\\aaaaa\\aaaa';
const folded = foldLine(line);

expect(folded.length).to.equal(2);
expect(line).to.equal(folded.join(''));
expect(folded).to.deep.equal([
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'",
"aaaaa'aaaa"
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\',
'aaaaa\\aaaa'
]);
});

it('should fold at default length', () => {
const expected = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pretium ',
'a nunc ac fringilla. Nulla laoreet tincidunt tincidunt. Proin tristique ',
'vestibulum mauris non aliquam. Vivamus volutpat odio nisl, sed placerat ',
'turpis sodales a. Vestibulum quis lectus ac elit sagittis sodales ac a ',
'felis. Nulla iaculis, nisl ut mattis fringilla, tortor quam tincidunt ',
'lorem, quis feugiat purus felis ut velit. Donec euismod eros ut leo ',
'lobortis tristique.'
];
const folded = foldLine(expected.join(''));
expect(folded).to.deep.equal(expected);
expect(folded.length).to.equal(7);
});

it('should force fold white space', () => {
const line = 'abc def ghi';
const folded = foldLine(line, 5);
Expand Down

0 comments on commit 3f65da7

Please sign in to comment.