MCPcopy Create free account
hub / github.com/denoland/std / fn

Function fn

csv/stringify_test.ts:20–581  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

18Deno.test({
19 name: "stringify() handles various inputs",
20 async fn(t) {
21 await t.step({
22 name: "Access array index using string",
23 fn() {
24 const columns = ["a"];
25 const data = [["foo"], ["bar"]];
26 const errorMessage = 'Property accessor is not of type "number"';
27 assertThrows(
28 () => stringify(data, { columns }),
29 TypeError,
30 errorMessage,
31 );
32 },
33 });
34 await t.step(
35 {
36 name: "Double quote in separator",
37
38 fn() {
39 const columns = [0];
40 const data = [["foo"], ["bar"]];
41 const errorMessage = [
42 "Separator cannot include the following strings:",
43 ' - U+0022: Quotation mark (")',
44 " - U+000D U+000A: Carriage Return + Line Feed (\\r\\n)",
45 ].join("\n");
46 const options = { separator: '"', columns };
47 assertThrows(
48 () => stringify(data, options),
49 TypeError,
50 errorMessage,
51 );
52 },
53 },
54 );
55 await t.step(
56 {
57 name: "CRLF in separator",
58 fn() {
59 const columns = [0];
60 const data = [["foo"], ["bar"]];
61 const errorMessage = [
62 "Separator cannot include the following strings:",
63 ' - U+0022: Quotation mark (")',
64 " - U+000D U+000A: Carriage Return + Line Feed (\\r\\n)",
65 ].join("\n");
66 const options = { separator: "\r\n", columns };
67 assertThrows(
68 () => stringify(data, options),
69 TypeError,
70 errorMessage,
71 );
72 },
73 },
74 );
75
76 await t.step(
77 {

Callers

nothing calls this directly

Calls 7

assertThrowsFunction · 0.90
stringifyFunction · 0.90
assertEqualsFunction · 0.90
assertStringIncludesFunction · 0.90
assertFunction · 0.90
includesMethod · 0.80
stepMethod · 0.45

Tested by

no test coverage detected