summaryrefslogtreecommitdiff
path: root/encoding/csv_test.ts
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2019-05-23 19:04:06 -0700
committerBert Belder <bertbelder@gmail.com>2019-05-29 09:50:12 -0700
commitb95f79d74cbcf3492abd95d4c90839e32f51399f (patch)
treed0c68f01c798da1e3b81930cfa58a5370c56775f /encoding/csv_test.ts
parent5b37b560fb047e1df6e6f68fcbaece922637a93c (diff)
io: refactor BufReader/Writer interfaces to be more idiomatic (denoland/deno_std#444)
Thanks Vincent Le Goff (@zekth) for porting over the CSV reader implementation. Fixes: denoland/deno_std#436 Original: https://github.com/denoland/deno_std/commit/0ee6334b698072b50c6f5ac8d42d34dc4c94b948
Diffstat (limited to 'encoding/csv_test.ts')
-rw-r--r--encoding/csv_test.ts35
1 files changed, 23 insertions, 12 deletions
diff --git a/encoding/csv_test.ts b/encoding/csv_test.ts
index 1ca68ea16..40a2abcef 100644
--- a/encoding/csv_test.ts
+++ b/encoding/csv_test.ts
@@ -437,20 +437,31 @@ for (const t of testCases) {
if (t.LazyQuotes) {
lazyquote = t.LazyQuotes;
}
- const actual = await readAll(new BufReader(new StringReader(t.Input)), {
- comma: comma,
- comment: comment,
- trimLeadingSpace: trim,
- fieldsPerRecord: fieldsPerRec,
- lazyQuotes: lazyquote
- });
+ let actual;
if (t.Error) {
- assert(!!actual[1]);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const e: any = actual[1];
- assertEquals(e.message, t.Error);
+ let err;
+ try {
+ actual = await readAll(new BufReader(new StringReader(t.Input)), {
+ comma: comma,
+ comment: comment,
+ trimLeadingSpace: trim,
+ fieldsPerRecord: fieldsPerRec,
+ lazyQuotes: lazyquote
+ });
+ } catch (e) {
+ err = e;
+ }
+ assert(err);
+ assertEquals(err.message, t.Error);
} else {
- const expected = [t.Output, null];
+ actual = await readAll(new BufReader(new StringReader(t.Input)), {
+ comma: comma,
+ comment: comment,
+ trimLeadingSpace: trim,
+ fieldsPerRecord: fieldsPerRec,
+ lazyQuotes: lazyquote
+ });
+ const expected = t.Output;
assertEquals(actual, expected);
}
}