-
Notifications
You must be signed in to change notification settings - Fork 33
/
index.js
74 lines (71 loc) · 2.21 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* eslint-env node, mocha */
require('dotenv').config();
var chai = require('chai');
chai.use(require('chai-http'));
chai.use(require('chai-as-promised'));
chai.should();
var replay = require('replay')
, Blink = require('../index.js')
, debug = require('debug')('test:index');
describe('Auth Token Login', () => {
let blink;
before(() => {
blink = new Blink('', '', {_token: process.env.BLINK_AUTH_TOKEN, _region_id: process.env.BLINK_REGION_ID, _network_id:process.env.BLINK_NETWORK_ID});
return blink.setupSystem().should.be.fulfilled;
});
after(() => {
blink = null;
});
it('should get clients', () => {
return blink.getClients().should.eventually.have.deep.property('clients');
});
it('should get cameras', () => {
return blink.getIDs().should.eventually.have.deep.property('_cameras');
});
});
describe('Password Login', () => {
let blink;
const username = process.env.BLINK_USERNAME || 'username';
const password = process.env.BLINK_PASSWORD || 'password';
before(() => {
blink = new Blink(username, password);
return blink.setupSystem().should.be.fulfilled;
});
after(() => {
blink = null;
});
it('should get clients', () => {
return blink.getClients().should.eventually.have.deep.property('clients');
});
it('should get cameras', () => {
blink.getIDs().then(_ => {
console.log(blink.networks);
})
return blink.getIDs().should.eventually.have.deep.property('_cameras');
});
it('should setupSystem properly', () => {
return blink.should.have.deep.property('_cameras');
});
});
describe('expired auth token', () => {
let blink;
before(() => {
replay.fixtures = './fixtures-failure/';
debug('replay.fixtures:', replay.fixtures);
blink = new Blink('', '', {
_token: process.env.BLINK_AUTH_TOKEN,
_region_id: process.env.BLINK_REGION_ID,
_network_id:process.env.BLINK_NETWORK_ID}
);
return blink.setupSystem().should.be.rejected;
});
after(() => {
blink = null;
});
it('should should reject due to failure', () => {
return blink.getClients().should.be.rejected;
});
it('getIDs should reject', () => {
return blink.getIDs().should.be.rejectedWith('Can\'t retrieve system status');
});
});