-
Notifications
You must be signed in to change notification settings - Fork 1
/
middleware.test.js
61 lines (52 loc) · 1.59 KB
/
middleware.test.js
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
const AltSource = require('./index')
/**
* @param {Function} middleware
* @param {any} reqArg
* @returns {void}
*/
function AMidTester(middleware, reqArg) {
let req = {...reqArg}
let res = {
json: (out) => {console.log(`res.json: called`, JSON.stringify(out))},
end: (out) => {console.log(`res.end: called`, out)}
}
let next = () => {console.log(`next(): called`)}
console.log("tester vars", req, res, next)
console.log("Middleware:", middleware(req, res, next))
}
/*AMidTester(AltSource.middleware({
name: "AltSource.js Test",
identifier: "space.charliecat.altsource.test",
website: "https://github.com/0Charliecat/altsource.js#readme",
subtitle: "Altsource.js Test Source",
description: "beeb boop",
publisher: "0CharlieCat",
}, { path: "/altsource.json" }), {
baseUrl: "/alt.json",
path: ""
})*/
const alt = new AltSource({
name: "AltSource.js Test",
identifier: "space.charliecat.altsource.test",
website: "https://github.com/0Charliecat/altsource.js#readme",
subtitle: "Altsource.js Test Source",
description: "beeb boop",
publisher: "0CharlieCat",
}, { path: "/altsource.json" })
AMidTester(AltSource.middleware(alt), {
baseUrl: "/altstore.json",
path: ""
})
alt.addApp({
name: "test App",
bundle: "space.charliecat.test.altsource.app",
version: "0",
versionDate: new Date(),
versionDescription: "Test app version 1.0",
downloadURL: "https://example.com/myapp_v1.1.ipa",
size: "100"
})
AMidTester(AltSource.middleware(alt), {
baseUrl: "/altstore.json",
path: ""
})