-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
53 lines (40 loc) · 1.37 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
47
48
49
50
51
52
53
'use strict';
const Minsh = require('./index');
const config = {
appName: process.env.appName,
datacenter: 'asia',
verbose: false,
admin: {
username: process.env.adminUsername,
password: process.env.adminPassword
},
bob: {
username: 'bob',
email: '[email protected]',
password: 'spongebob'
}
};
var M = new Minsh(config.appName, 'asia', config.verbose);
(async function() {
let err, admin, bob, data;
[err, admin] = await M.login({'username_or_email': config.admin.username, password: config.admin.password});
if (err) { throw err + ' ' + admin; }
[err, bob] = await M.adminCreateAccount({token: admin.token, ...config.bob});
if (err) { throw err + ' ' + admin; }
/* login with bob */
[err, bob] = await M.login({'username_or_email': config.bob.username, password: config.bob.password});
if (err) { throw err + ' ' + admin; }
/* post shout */
[err, data] = await M.createShout({token: bob.token, shout: 'hello world!'});
if (err) { throw err + ' ' + admin; }
console.log(data);
/* logout bob */
[err, data] = await M.logout({token: bob.token});
if (err) { throw err + ' ' + admin; }
/* delete bob */
[err, data] = await M.deleteAccount(bob.id, {token: admin.token});
if (err) { throw err + ' ' + admin; }
/* admin logout */
[err, data] = await M.logout({token: admin.token});
if (err) { throw err + ' ' + data; }
}());