deno.land / std@0.224.0 / http / user_agent_test.ts

user_agent_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../assert/assert_equals.ts";import { UserAgent } from "./user_agent.ts";
Deno.test({ name: "UserAgent.prototype.browser", async fn(t) { const specs = (await import("./testdata/user_agent/browser-all.json", { with: { type: "json" }, })).default; for (const { desc, ua, expect: { major, name, version } } of specs) { await t.step({ name: desc, fn() { const actual = new UserAgent(ua); assertEquals(actual.browser, { major: major === "undefined" ? undefined : major, name: name === "undefined" ? undefined : name, version: version === "undefined" ? undefined : version, }); }, }); } },});
Deno.test({ name: "UserAgent.prototype.cpu", async fn(t) { const specs = (await import("./testdata/user_agent/cpu-all.json", { with: { type: "json" }, })).default; for (const { desc: name, ua, expect } of specs) { await t.step({ name, fn() { const actual = new UserAgent(ua); assertEquals(actual.cpu, expect); }, }); } },});
Deno.test({ name: "UserAgent.prototype.device", async fn(t) { const specs = (await import("./testdata/user_agent/device-all.json", { with: { type: "json" }, })).default; for (const { desc: name, ua, expect: { vendor, model, type } } of specs) { await t.step({ name, fn() { const actual = new UserAgent(ua); assertEquals(actual.device, { vendor: vendor === "undefined" ? undefined : vendor, model: model === "undefined" ? undefined : model, type: type === "undefined" ? undefined : type, }); }, }); } },});
Deno.test({ name: "UserAgent.prototype.engine", async fn(t) { const specs = (await import("./testdata/user_agent/engine-all.json", { with: { type: "json" }, })).default; for (const { desc, ua, expect: { name, version } } of specs) { await t.step({ name: desc, fn() { const actual = new UserAgent(ua); assertEquals(actual.engine, { name: name === "undefined" ? undefined : name, version: version === "undefined" ? undefined : version, }); }, }); } },});
Deno.test({ name: "UserAgent.prototype.os", async fn(t) { const specs = (await import("./testdata/user_agent/os-all.json", { with: { type: "json" }, })).default; for (const { desc, ua, expect: { name, version } } of specs) { await t.step({ name: desc, fn() { const actual = new UserAgent(ua); assertEquals(actual.os, { name: name === "undefined" ? undefined : name, version: version === "undefined" ? undefined : version, }); }, }); } },});
std

Version Info

Tagged at
3 weeks ago