8000 Tests: Move test code to separate file · PrashanthaTP/leetcode-client@62a491d · GitHub
[go: up one dir, main page]

Skip to content

Commit 62a491d

Browse files
committed
Tests: Move test code to separate file
+ Also add cmd to run tests in package.json
1 parent 4a061bc commit 62a491d

File tree

3 files changed

+43
-33
lines changed

3 files changed

+43
-33
lines changed

index.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,3 @@ import axios from "axios";
22
import config from "./config/config";
33
import queries from "./queries/queries";
44

5-
6-
const testPostReq = async () => {
7-
const data = await axios({
8-
url: "http://localhost:8000/api/get",
9-
method: "POST",
10-
data: {
11-
LEETCODE_SESSION: config.LEETCODE_SESSION,
12-
CSRFTOKEN: config.CSRFTOKEN,
13-
queryData: queries.getDailyChallengeQuery,
14-
},
15-
});
16-
return data.data.data;
17-
};
18-
19-
console.log(
20-
testPostReq().then((res) =>
21-
console.log(res.data.data.activeDailyCodingChallengeQuestion.question)
22-
)
23-
);

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
2-
"name": "leetcode",
3-
"type": "module",
4-
"version": "1.0.0",
5-
"description": "",
6-
"main": "index.js",
7-
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1"
9-
},
10-
"keywords": [],
11-
"author": "",
12-
"license": "ISC",
13-
"dependencies": {
14-
"axios": "^1.1.3"
15-
}
2+
"name": "leetcode",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "node --experimental-specifier-resolution=node tests/test.js",
9+
"start": "node --experimental-specifier-resolution=node index.js"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "ISC",
14+
"dependencies": {
15+
"axios": "^1.1.3"
16+
}
1617
}

tests/test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import axios from "axios";
2+
3+
import config from "../config/config";
4+
import queries from "../queries/queries";
5+
6+
const testPostReq = async () => {
7+
const data = await axios({
8+
url: "http://localhost:8000/api/v1/query",
9+
method: "POST",
10+
data: {
11+
LEETCODE_SESSION: config.env.LEETCODE_SESSION,
12+
CSRFTOKEN: config.env.CSRFTOKEN,
13+
queryData: queries.getDailyChallengeQuery,
14+
},
15+
});
16+
return data.data.data;
17+
};
18+
19+
const test = () => {
20+
console.log(
21+
testPostReq().then((res) =>
22+
// console.log(res.data.data.activeDailyCodingChallengeQuestion.question)
23+
console.log(res.data)
24+
)
25+
);
26+
};
27+
28+
test()

0 commit comments

Comments
 (0)
0