forked from olalonde/Google-Contacts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
28 lines (22 loc) · 756 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
var GoogleContacts = require('./index');
var assert = require('assert');
var token;
function test(token, cb) {
var contacts = new GoogleContacts({ token : token });
contacts.getContacts(cb);
}
// test proper failure on invalid access
test(token, function(err, contacts) {
assert(typeof err !== "undefined", "err should not be undefined");
});
// test proper success on valid access
token = process.env.GOOGLE_API_TOKEN;
if (!token) {
console.log("$GOOGLE_API_TOKEN must be set");
process.exit(1);
}
test(token, function(err, contacts) {
assert(!err, "err should falsey");
assert(typeof contacts !== "undefined", "contacts should be defined");
assert(!!contacts.length, "more than one contact should be returned");
});