|
| 1 | +import { parseListFields } from "./list.ts"; |
| 2 | +import { assertEquals, describe, it } from "./_dev_deps.ts"; |
| 3 | + |
| 4 | +describe("parseListFields", () => { |
| 5 | + it("should ", () => { |
| 6 | + const table: [string, string[]][] = [ |
| 7 | + ["", []], |
| 8 | + ["a", ["a"]], |
| 9 | + ["a, b, c", ["a", "b", "c"]], |
| 10 | + [" a, a , a ", ["a", "a", "a"]], |
| 11 | + [`"", `, [`""`]], |
| 12 | + [`","`, [`","`]], |
| 13 | + [`",", `, [`","`]], |
| 14 | + [`"," ,`, [`","`]], |
| 15 | + [`",,," ,`, [`",,,"`]], |
| 16 | + [`"," , " , "`, [`","`, `" , "`]], |
| 17 | + [`","abc,`, [`","abc`]], |
| 18 | + ["a, b,,,,", ["a", "b"]], |
| 19 | + ["a, b, c", ["a", "b", "c"]], |
| 20 | + ["a,b,c", ["a", "b", "c"]], |
| 21 | + ["a,,c", ["a", "c"]], |
| 22 | + [",,,", []], |
| 23 | + [`"a,b"`, [`"a,b"`]], |
| 24 | + [`"a,b",c, "d,e", f f , g `, [`"a,b"`, "c", `"d,e"`, "f f", "g"]], |
| 25 | + [` complex,pattern,"abc", "abc , def", ,,,, """, , ",""`, [ |
| 26 | + "complex", |
| 27 | + "pattern", |
| 28 | + `"abc"`, |
| 29 | + `"abc , def"`, |
| 30 | + `""", , "`, |
| 31 | + `""`, |
| 32 | + ]], |
| 33 | + [`",","`, [`"`, `","`]], |
| 34 | + [`",",","`, [`","`, `","`]], |
| 35 | + [`",",",",`, [`","`, `","`]], |
| 36 | + [`",",",","`, [`"`, `","`, `","`]], |
| 37 | + [`",",",",",`, [`"`, `","`, `","`]], |
| 38 | + [`",",",",","`, [`","`, `","`, `","`]], |
| 39 | + [`"`, [`"`]], |
| 40 | + [`""`, [`""`]], |
| 41 | + [`"""`, [`"""`]], |
| 42 | + [`""""`, [`""""`]], |
| 43 | + [`"",""`, [`""`, `""`]], |
| 44 | + [`",",`, [`","`]], |
| 45 | + [`"abc,def", "efg, hij", "lmn, opq"`, [ |
| 46 | + '"abc,def"', |
| 47 | + '"efg, hij"', |
| 48 | + '"lmn, opq"', |
| 49 | + ]], |
| 50 | + ]; |
| 51 | + |
| 52 | + table.forEach(([input, expected]) => { |
| 53 | + assertEquals(parseListFields(input), expected); |
| 54 | + }); |
| 55 | + }); |
| 56 | +}); |
0 commit comments