|
| 1 | +import { parseOptions } from "../parseOptions"; |
| 2 | + |
| 3 | +describe("parseOptions", () => { |
| 4 | + it("should parse simple string array", () => { |
| 5 | + const input = ["one two", "three"]; |
| 6 | + const expected = ["one", "two", "three"]; |
| 7 | + expect(parseOptions(input)).toEqual(expected); |
| 8 | + }); |
| 9 | + |
| 10 | + it("should handle empty array", () => { |
| 11 | + expect(parseOptions([])).toEqual([]); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should parse quoted strings correctly", () => { |
| 15 | + const input = ['"hello world"', '"goodbye world"']; |
| 16 | + const expected = ['"hello world"', '"goodbye world"']; |
| 17 | + expect(parseOptions(input)).toEqual(expected); |
| 18 | + }); |
| 19 | + |
| 20 | + it("should handle mixed quoted and unquoted strings", () => { |
| 21 | + const input = ['simple "quoted value" unquoted']; |
| 22 | + const expected = ["simple", '"quoted value"', "unquoted"]; |
| 23 | + expect(parseOptions(input)).toEqual(expected); |
| 24 | + }); |
| 25 | + |
| 26 | + it("should handle empty strings", () => { |
| 27 | + const input = [""]; |
| 28 | + expect(parseOptions(input)).toEqual([]); |
| 29 | + }); |
| 30 | + |
| 31 | + it("should handle multiple spaces between options", () => { |
| 32 | + const input = ["one two three"]; |
| 33 | + const expected = ["one", "two", "three"]; |
| 34 | + expect(parseOptions(input)).toEqual(expected); |
| 35 | + }); |
| 36 | + |
| 37 | + it("should preserve quoted strings with spaces", () => { |
| 38 | + const input = ['"this is one" "this is two"', "'this is three'"]; |
| 39 | + const expected = [ |
| 40 | + '"this is one"', |
| 41 | + '"this is two"', |
| 42 | + "'this is three'", |
| 43 | + ]; |
| 44 | + expect(parseOptions(input)).toEqual(expected); |
| 45 | + }); |
| 46 | +}); |
0 commit comments