forked from TuyaAPI/cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
32 lines (24 loc) · 941 Bytes
/
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
import test from 'ava';
const apiKeys = require('./keys.json');
const Cloud = require('.');
const api = new Cloud({key: apiKeys.key, secret: apiKeys.secret});
test('register a new user', async t => {
const apiResult = await api.register({email: '[email protected]',
password: 'example-password'});
t.is(apiResult.length, 56);
});
test('login a user', async t => {
const apiResult = await api.login({email: '[email protected]',
password: 'example-password'});
t.is(apiResult.length, 56);
});
test('create a token', async t => {
await api.register({email: '[email protected]',
password: 'example-password'});
const token = await api.request({action: 'tuya.m.device.token.create',
data: {timeZone: '+08:00'}});
if (token.secret && token.token) {
t.pass();
}
});
test.todo('wait for token');