-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
37 lines (36 loc) · 1.46 KB
/
tests.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
async function testAccounts(){
var accounts = require("./accounts");
try{
const test_user={"username" : "test_user", "password" : "test_password"}
await accounts.remove(test_user.username);
await accounts.register(test_user.username, test_user.password);
console.log(await accounts.get(test_user.username));
console.log((await accounts.list(test_user.username)).length);
await accounts.login(test_user.username, test_user.password);
console.log("logged in.");
await accounts.remove(test_user.username);
console.log("removed test user.");
console.log(await accounts.get(test_user.username));
console.log((await accounts.list(test_user.username)).length);
}catch(err){
console.log(err);
}
process.exit();
}
async function testPosts(){
var posts = require("./posts");
try{
const test_post={"author" : "test_author", "title" : "test_title", "content" : "test_content"}
var id=await posts.create(test_post.author, test_post.title, test_post.content);
console.log(await posts.get(id));
console.log(await posts.all());
await posts.edit(id, test_post.author, test_post.title+" edited", test_post.content);
console.log(await posts.get(id));
await posts.remove(id);
console.log("removed the post.");
}catch(err){
console.log(err);
}
process.exit();
}
testPosts();