deno.land / std@0.166.0 / http / http_status_test.ts

http_status_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
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { isClientErrorStatus, isErrorStatus, isInformationalStatus, isRedirectStatus, isServerErrorStatus, isSuccessfulStatus, Status, STATUS_TEXT,} from "./http_status.ts";import { assert, assertEquals } from "../testing/asserts.ts";
Deno.test({ name: "http/http_status - Status", fn() { // just spot check a few common codes assertEquals(Status.OK, 200); assertEquals(Status.NoContent, 204); assertEquals(Status.NotFound, 404); assertEquals(Status.InternalServerError, 500); },});
Deno.test({ name: "http/http_status - STATUS_TEXT", fn() { // just spot check a few common codes assertEquals(STATUS_TEXT[Status.OK], "OK"); assertEquals(STATUS_TEXT[Status.NoContent], "No Content"); assertEquals(STATUS_TEXT[Status.NotFound], "Not Found"); assertEquals( STATUS_TEXT[Status.InternalServerError], "Internal Server Error", ); },});
Deno.test({ name: "http/http_status - isInformationalStatus()", fn() { assert(isInformationalStatus(Status.Continue)); assert(!isInformationalStatus(Status.OK)); assert(isInformationalStatus(101)); assert(!isInformationalStatus(300)); },});
Deno.test({ name: "http/http_status - isSuccessfulStatus()", fn() { assert(isSuccessfulStatus(Status.OK)); assert(!isSuccessfulStatus(Status.NotFound)); assert(isSuccessfulStatus(204)); assert(!isSuccessfulStatus(100)); },});
Deno.test({ name: "http/http_status - isRedirectStatus()", fn() { assert(isRedirectStatus(Status.Found)); assert(!isRedirectStatus(Status.NotFound)); assert(isRedirectStatus(301)); assert(!isRedirectStatus(200)); },});
Deno.test({ name: "http/http_status - isClientErrorStatus()", fn() { assert(isClientErrorStatus(Status.NotFound)); assert(!isClientErrorStatus(Status.InternalServerError)); assert(isClientErrorStatus(400)); assert(!isClientErrorStatus(503)); },});
Deno.test({ name: "http/http_status - isServerErrorStatus()", fn() { assert(isServerErrorStatus(Status.InternalServerError)); assert(!isServerErrorStatus(Status.NotFound)); assert(isServerErrorStatus(503)); assert(!isServerErrorStatus(400)); },});
Deno.test({ name: "http/http_status - isErrorStatus()", fn() { assert(isErrorStatus(Status.InternalServerError)); assert(isErrorStatus(Status.NotFound)); assert(isErrorStatus(503)); assert(isErrorStatus(400)); assert(!isErrorStatus(Status.OK)); assert(!isErrorStatus(Status.MovedPermanently)); assert(!isErrorStatus(100)); assert(!isErrorStatus(204)); },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2457

Version Info

Tagged at
2 months ago