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

status_test.ts
View Documentation
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
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { isClientErrorStatus, isErrorStatus, isInformationalStatus, isRedirectStatus, isServerErrorStatus, isSuccessfulStatus, STATUS_CODE, STATUS_TEXT,} from "./status.ts";import { assert, assertEquals } from "../assert/mod.ts";
Deno.test({ name: "STATUS_CODE", fn() { // just spot check a few common codes assertEquals(STATUS_CODE.OK, 200); assertEquals(STATUS_CODE.NoContent, 204); assertEquals(STATUS_CODE.NotFound, 404); assertEquals(STATUS_CODE.InternalServerError, 500); },});
Deno.test({ name: "STATUS_TEXT", fn() { // just spot check a few common codes assertEquals(STATUS_TEXT[STATUS_CODE.OK], "OK"); assertEquals(STATUS_TEXT[STATUS_CODE.NoContent], "No Content"); assertEquals(STATUS_TEXT[STATUS_CODE.NotFound], "Not Found"); assertEquals( STATUS_TEXT[STATUS_CODE.InternalServerError], "Internal Server Error", ); },});
Deno.test({ name: "isInformationalStatus()", fn() { assert(isInformationalStatus(STATUS_CODE.Continue)); assert(!isInformationalStatus(STATUS_CODE.OK)); assert(isInformationalStatus(101)); assert(!isInformationalStatus(300)); },});
Deno.test({ name: "isSuccessfulStatus()", fn() { assert(isSuccessfulStatus(STATUS_CODE.OK)); assert(!isSuccessfulStatus(STATUS_CODE.NotFound)); assert(isSuccessfulStatus(204)); assert(!isSuccessfulStatus(100)); },});
Deno.test({ name: "isRedirectStatus()", fn() { assert(isRedirectStatus(STATUS_CODE.Found)); assert(!isRedirectStatus(STATUS_CODE.NotFound)); assert(isRedirectStatus(301)); assert(!isRedirectStatus(200)); },});
Deno.test({ name: "isClientErrorStatus()", fn() { assert(isClientErrorStatus(STATUS_CODE.NotFound)); assert(!isClientErrorStatus(STATUS_CODE.InternalServerError)); assert(isClientErrorStatus(400)); assert(!isClientErrorStatus(503)); },});
Deno.test({ name: "isServerErrorStatus()", fn() { assert(isServerErrorStatus(STATUS_CODE.InternalServerError)); assert(!isServerErrorStatus(STATUS_CODE.NotFound)); assert(isServerErrorStatus(503)); assert(!isServerErrorStatus(400)); },});
Deno.test({ name: "isErrorStatus()", fn() { assert(isErrorStatus(STATUS_CODE.InternalServerError)); assert(isErrorStatus(STATUS_CODE.NotFound)); assert(isErrorStatus(503)); assert(isErrorStatus(400)); assert(!isErrorStatus(STATUS_CODE.OK)); assert(!isErrorStatus(STATUS_CODE.MovedPermanently)); assert(!isErrorStatus(100)); assert(!isErrorStatus(204)); },});
std

Version Info

Tagged at
6 months ago