forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.spec.ts
60 lines (58 loc) · 1.89 KB
/
globals.spec.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
import { describe, it, expect } from '@gjsify/unit';
import '@gjsify/deno-runtime/globals';
export default async () => {
await describe('location.href', async () => {
await it('should return "https://example.com/path"', async () => {
expect(location.href).toBe("https://example.com/path");
});
});
await describe('location.toString()', async () => {
await it('should return "https://example.com/path"', async () => {
expect(location.toString()).toBe("https://example.com/path");
});
});
await describe('location.host', async () => {
await it('should return "example.com"', async () => {
expect(location.host).toBe("example.com");
});
});
await describe('location.port', async () => {
await it('should return ""', async () => {
expect(location.port).toBe("");
});
});
await describe('location.pathname', async () => {
await it('should return "/path"', async () => {
expect(location.pathname).toBe("/path");
});
});
await describe('location.origin', async () => {
await it('should return "https://example.com"', async () => {
expect(location.origin).toBe("https://example.com");
});
});
await describe('location.protocol', async () => {
await it('should return "https:"', async () => {
expect(location.protocol).toBe("https:");
});
});
await describe('location.search', async () => {
await it('should return ""', async () => {
expect(location.search).toBe("");
});
});
await describe('btoa', async () => {
await it('should return "aGVsbG8gd29ybGQ=" for "hello world"', async () => {
const text = "hello world";
const encoded = btoa(text);
expect(encoded).toBe("aGVsbG8gd29ybGQ=");
});
});
await describe('atob', async () => {
await it('should return "hello world" for "aGVsbG8gd29ybGQ="', async () => {
const encoded = "aGVsbG8gd29ybGQ=";
const decoded = atob(encoded);
expect(decoded).toBe("hello world");
});
});
}