-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
46 lines (41 loc) · 1.25 KB
/
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
import { readFileSync } from 'fs';
import conf from './config/secret.json' assert { type: 'json' };
import { postToServer } from './lib.js';
import fetch from 'node-fetch';
const { password } = conf;
const generatePostElement = () => {
return {
controller: {},
difficulty: 'test',
formattedTitle: '99999-second-sample',
suffix: '',
url: 'http://jasontung.me:3001',
code: `
# this is a sample code
# random number here: ${Math.random()}
def main():
print("hello wrld")
`,
password,
// posturl: 'http://localhost:3001/updateGithub',
fetchMethod: fetch,
};
};
const noSuffixPostElement = generatePostElement();
const suffixPostElement = {
...generatePostElement(),
suffix: 'this-is-suffix',
};
const improperTitleElement = {
...generatePostElement(),
suffix: 'this-is=suffix',
};
const doTests = async () => {
const noSuffixRet = await postToServer(noSuffixPostElement);
console.log(await noSuffixRet.text());
const suffixRet = await postToServer(suffixPostElement);
console.log(await suffixRet.text());
const improperRet = await postToServer(improperTitleElement);
console.log(improperRet.status);
};
doTests();