-
Notifications
You must be signed in to change notification settings - Fork 7
/
mod.test.ts
40 lines (34 loc) 路 910 Bytes
/
mod.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
// Copyright 2021-2024 Kitson P. Kelly. All rights reserved. MIT License.
/// <reference types="./globals.d.ts" />
import { assert } from "jsr:/@std/assert@0.220/assert";
import { assertThrows } from "jsr:/@std/assert@0.220/assert_throws";
import "./mod.ts";
Deno.test({
name: "globals defined",
fn() {
assert(typeof XMLHttpRequest === "function");
assert(typeof XMLHttpRequestEventTarget === "function");
assert(typeof XMLHttpRequestUpload === "function");
},
});
Deno.test({
name: "forbidden methods",
fn() {
const xhr = new XMLHttpRequest();
assertThrows(
() => {
xhr.open("TRACE", "http://127.0.0.1");
},
DOMException,
`The method "TRACE" is forbidden.`,
);
},
});
Deno.test({
name: "non-standard methods work",
fn() {
const xhr = new XMLHttpRequest();
xhr.open("CHICKEN", "http://127.0.0.1");
xhr.abort();
},
});