deno.land / std@0.166.0 / media_types / _util_test.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../testing/asserts.ts";import { consumeMediaParam, consumeToken, consumeValue } from "./_util.ts";
Deno.test({ name: "media_types::util - consumeToken()", fn() { const fixtures = [ ["foo bar", "foo", " bar"], ["bar", "bar", ""], ["", "", ""], [" foo", "", " foo"], ] as const; for (const [fixture, token, rest] of fixtures) { assertEquals(consumeToken(fixture), [token, rest]); } },});
Deno.test({ name: "media_types::util - consumeValue()", fn() { const fixtures = [ ["foo bar", "foo", " bar"], ["bar", "bar", ""], [" bar ", "", " bar "], [`"My value"end`, "My value", "end"], [`"My value" end`, "My value", " end"], [`"\\\\" rest`, "\\", " rest"], [`"My \\" value"end`, 'My " value', "end"], [`"\\" rest`, "", `"\\" rest`], [`"C:\\dev\\go\\robots.txt"`, `C:\\dev\\go\\robots.txt`, ""], [`"C:\\新建文件夹\\中文第二次测试.mp4"`, `C:\\新建文件夹\\中文第二次测试.mp4`, ""], ] as const; for (const [fixture, value, rest] of fixtures) { assertEquals(consumeValue(fixture), [value, rest]); } },});
Deno.test({ name: "media_types::util - consumeMediaParam()", fn() { const fixtures = [ [" ; foo=bar", "foo", "bar", ""], ["; foo=bar", "foo", "bar", ""], [";foo=bar", "foo", "bar", ""], [";FOO=bar", "foo", "bar", ""], [`;foo="bar"`, "foo", "bar", ""], [`;foo="bar"; `, "foo", "bar", "; "], [`;foo="bar"; foo=baz`, "foo", "bar", "; foo=baz"], [` ; boundary=----CUT;`, "boundary", "----CUT", ";"], [ ` ; key=value; blah="value";name="foo" `, "key", "value", `; blah="value";name="foo" `, ], [`; blah="value";name="foo" `, "blah", "value", `;name="foo" `], [`;name="foo" `, "name", "foo", ` `], ] as const; for (const [fixture, key, value, rest] of fixtures) { assertEquals(consumeMediaParam(fixture), [key, value, rest]); } },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago