misc_pterodactyl-panel/resources/scripts/helpers/splitStringWhitespace.spec.ts

19 lines
861 B
TypeScript
Raw Normal View History

2023-01-12 19:44:49 +00:00
import { describe, expect, it } from 'vitest';
import splitStringWhitespace from '@/helpers/splitStringWhitespace';
describe('@/helpers/splitStringWhitespace.ts', function () {
it.each([
2023-01-12 19:31:47 +00:00
['', []],
['hello world', ['hello', 'world']],
[' hello world ', ['hello', 'world']],
['hello123 world 123 $$ s ', ['hello123', 'world', '123', '$$', 's']],
['hello world! how are you?', ['hello', 'world!', 'how', 'are', 'you?']],
['hello "foo bar baz" world', ['hello', 'foo bar baz', 'world']],
['hello "foo \\"bar bar \\" baz" world', ['hello', 'foo "bar bar " baz', 'world']],
['hello "foo "bar baz" baz" world', ['hello', 'foo bar', 'baz baz', 'world']],
])('should handle string: %s', function (input, output) {
expect(splitStringWhitespace(input)).toStrictEqual(output);
});
});