feat(list-converter): a small converter who deals with column based data and do some stuff with it (#387)

* feat(list-converter): a small converter who deals with column based data and do some stuff with it

* Update src/tools/list-converter/index.ts

* Update src/tools/list-converter/index.ts

* Update src/tools/list-converter/index.ts

---------

Co-authored-by: Corentin THOMASSET <corentin.thomasset74@gmail.com>

fix(list-format): fix e2e
This commit is contained in:
cgoIT 2023-05-07 11:29:22 +02:00 committed by Corentin Thomasset
parent ce3150c65d
commit 83a7b3bae9
No known key found for this signature in database
GPG key ID: DBD997E935996158
9 changed files with 441 additions and 139 deletions

View file

@ -0,0 +1,76 @@
import { expect, describe, it } from 'vitest';
import { convert } from './list-converter.models';
import type { ConvertOptions } from './list-converter.types';
describe('list-converter', () => {
describe('convert', () => {
it('should convert a given list', () => {
const options: ConvertOptions = {
separator: ', ',
trimItems: true,
removeDuplicates: true,
itemPrefix: '"',
itemSuffix: '"',
listPrefix: '',
listSuffix: '',
reverseList: false,
sortList: null,
lowerCase: false,
keepLineBreaks: false,
};
const input = `
1
2
3
3
4
`;
expect(convert(input, options)).toEqual('"1", "2", "3", "4"');
});
it('should return an empty value for an empty input', () => {
const options: ConvertOptions = {
separator: ', ',
trimItems: true,
removeDuplicates: true,
itemPrefix: '',
itemSuffix: '',
listPrefix: '',
listSuffix: '',
reverseList: false,
sortList: null,
lowerCase: false,
keepLineBreaks: false,
};
expect(convert('', options)).toEqual('');
});
it('should keep line breaks', () => {
const options: ConvertOptions = {
separator: '',
trimItems: true,
itemPrefix: '<li>',
itemSuffix: '</li>',
listPrefix: '<ul>',
listSuffix: '</ul>',
keepLineBreaks: true,
lowerCase: false,
removeDuplicates: false,
reverseList: false,
sortList: null,
};
const input = `
1
2
3
`;
const expected = `<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>`;
expect(convert(input, options)).toEqual(expected);
});
});
});