-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.test.js
More file actions
68 lines (63 loc) · 2.09 KB
/
api.test.js
File metadata and controls
68 lines (63 loc) · 2.09 KB
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
// windows only test
import index from "./index.js"
import * as java from "./java.js"
import { describe, it, expect } from "vitest"
import fs from "fs/promises"
describe("API exists", () => {
it("Should be defined", () => {
expect(index).toBeDefined()
})
})
describe("API methods", () => {
it("Can get OS name", () => {
expect(index.getOSName()).toBeDefined()
expect(index.getOSName()).eq("windows")
})
it("Can check rules", () => {
expect(index.checkRule({
"action": "allow",
"os": {
"name": "osx"
}
})).eq(false)
expect(index.checkRule({
"action": "allow",
"os": {
"name": "linux"
}
})).eq(false)
expect(index.checkRule({
"action": "allow",
"os": {
"name": "windows"
}
})).eq(true)
})
})
describe("Java API", () => {
it("Should be defined", () => {
expect(java.downloadJava).toBeDefined()
expect(java.downloadJava).toBeTypeOf("function")
})
})
describe("Can handle manifest", () => {
it("Should be defined", async () => {
expect(await index.loadManifest("neoforge-21.1.162.json")).toBeDefined()
})
it("Should merge Manifests", async () => {
expect(await index.mergeManifests(await index.loadManifest("neoforge-21.1.162.json"), await index.loadManifest("1.21.1.json"))).toBeDefined()
expect(await index.mergeManifests(await index.loadManifest("neoforge-21.1.162.json"), await index.loadManifest("1.21.1.json"))).toBeTypeOf("object")
})
})
describe("Misc functions", () => {
it("Should be defined", async () => {
expect(index.downloadFile).toBeDefined()
})
it("Should download file", async () => {
await fs.rm("test.txt", { force: true })
const download = await index.downloadFile("https://sample-files.com/downloads/documents/txt/simple.txt", "test.txt")
expect(download).toBeDefined()
expect(download).toBeTypeOf("boolean")
expect(download).eq(true)
})
})