diff --git a/lib/svgo.test.js b/lib/svgo.test.js
index 405810956..71102b33d 100644
--- a/lib/svgo.test.js
+++ b/lib/svgo.test.js
@@ -64,6 +64,122 @@ test('allow to disable and customize plugins in preset', () => {
`);
});
+describe('allow to configure EOL', () => {
+ test('should respect EOL set to LF', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, {
+ js2svg: { eol: 'lf', pretty: true, indent: 2 },
+ });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ '\n'
+ );
+ });
+
+ test('should respect EOL set to CRLF', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, {
+ js2svg: { eol: 'crlf', pretty: true, indent: 2 },
+ });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ '\r\n'
+ );
+ });
+
+ test('should default to LF line break for any other EOL values', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, {
+ js2svg: { eol: 'invalid', pretty: true, indent: 2 },
+ });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ '\n'
+ );
+ });
+});
+
+describe('allow to configure final newline', () => {
+ test('should not add final newline when unset', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, { js2svg: { eol: 'lf' } });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ ''
+ );
+ });
+
+ test('should add final newline when set', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, {
+ js2svg: { finalNewline: true, eol: 'lf' },
+ });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ '\n'
+ );
+ });
+
+ test('should not add extra newlines when using pretty: true', () => {
+ const svg = `
+
+
+ `;
+ const { data } = optimize(svg, {
+ js2svg: { finalNewline: true, pretty: true, indent: 2, eol: 'lf' },
+ });
+ // using toEqual because line endings matter in these tests
+ expect(data).toEqual(
+ '\n'
+ );
+ });
+});
+
test('allow to customize precision for preset', () => {
const svg = `