This repository has been archived by the owner on Sep 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
demo.js
76 lines (68 loc) · 2.57 KB
/
demo.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {InfoHelper} from "./dist";
import {question, keyInYNStrict} from "readline-sync";
(async () => {
const userId = question("请输入学号:");
const password = question("请输入密码:", { hideEchoBack: true });
const helper = new InfoHelper();
await helper.login(
{
userId: userId,
password: password,
},
);
// Go on with your code here.
if (keyInYNStrict("测试点一:获取成绩单。是否进行测试?")) {
try {
const report = await helper.getReport(false, true);
console.log(`共有 ${report.length} 条成绩记录。`);
console.log("测试点一通过。");
} catch (e) {
console.error(e);
console.error("测试点一未通过。");
}
}
if (keyInYNStrict("测试点二:获取新闻动态。是否进行测试?")) {
try {
const news = await helper.getNewsList(1, 20);
console.log(`共有 ${news.length} 条新闻记录。`);
if (news.length === 20) {
console.log("测试点二通过。");
} else {
console.error("测试点二未通过。");
}
} catch (e) {
console.error(e);
console.error("测试点二未通过。");
}
}
if (keyInYNStrict("测试点三:获取课程表。是否进行测试?")) {
try {
const schedule = await helper.getSchedule(1, 20);
console.log(`共有 ${schedule.length} 条课程表记录。`);
console.log("测试点三通过。");
} catch (e) {
console.error(e);
console.error("测试点三未通过。");
}
}
if (keyInYNStrict("测试点四:获取校园卡消费记录。是否进行测试?")) {
try {
const expenditures = await helper.getExpenditures();
console.log(`共有 ${expenditures.length} 条校园卡消费记录。`);
console.log("测试点四通过。");
} catch (e) {
console.error(e);
console.error("测试点四未通过。");
}
}
if (keyInYNStrict("测试点五:获取宿舍电费余额。是否进行测试?")) {
try {
const {remainder} = await helper.getEleRemainder();
console.log(`余额 ${remainder} 度。`);
console.log("测试点五通过。");
} catch (e) {
console.error(e);
console.error("测试点五未通过。");
}
}
})().catch(console.error);