forked from arei/node-untappd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.js
97 lines (73 loc) · 2.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// This tests a client connection to untapped.
// We're only doing read-only tests. Anything which would modify you
// can figure out for yourself.
//
// By Glen R. Goodwin
// twitter: @areinet
// Imports
var UntappdClient = require("./UntappdClient");
// Definitions
var clientId = process.env['UNTAPPD_CLIENT_ID'] || '';
var clientSecret = process.env['UNTAPPD_CLIENT_SECRET'] || '';
var accessToken = process.env['UNTAPPD_ACCESS_TOKEN'] || '';
var debug = false;
var sampleUser = "arei";
var beer_id = "1";
var brewery_id = "1";
var checkin_id = "1";
var venue_id = "1";
var foursquare_id = "4ccf5fec1ac7a1cd6a5c1392";
// Handles testing our results
var goodbadResults = function(name) {
return function(err,obj){
if (debug) console.log(name,err,obj);
if (err || !obj || obj.meta.code>=400 || !obj.response) {
console.log("[ FAIL ] " + name);
console.error("\t" + obj.meta.error_detail);
return;
}
console.log("[ PASS ] "+name);
};
};
console.log("Testing all the READ-ONLY Services for Untappd");
console.log("----------------------------------------------");
// Create Client
var untappd = new UntappdClient(debug);
untappd.setClientId(clientId);
untappd.setClientSecret(clientSecret);
untappd.setAccessToken(accessToken);
// get the url for getting an oauth token
console.log("[ INFO ] OAUTH Url: "+untappd.getUserAuthenticationURL("http://localhost:3000/auth"));
console.log("");
// Test userActivityFeed
untappd.userActivityFeed(goodbadResults("userActivityFeed"),{USERNAME:sampleUser});
// Test pubFeed
untappd.pubFeed(goodbadResults("pubFeed"), {lat:40, lng:74});
// Test venueActivityFeed
untappd.venueActivityFeed(goodbadResults("venueActivityFeed"),{VENUE_ID:venue_id});
// Test beerActivityFeed
untappd.beerActivityFeed(goodbadResults("beerActivityFeed"),{BID:beer_id});
// Test breweryFeed
untappd.breweryActivityFeed(goodbadResults("breweryActivityFeed"),{BREWERY_ID:brewery_id});
// Test userInfo
untappd.userInfo(goodbadResults("userInfo"),{USERNAME: sampleUser});
// Test userWishList
untappd.userWishList(goodbadResults("userWishList"),{USERNAME: sampleUser});
// Test userFriends
untappd.userFriends(goodbadResults("userFriends"),{USERNAME: sampleUser});
// Test userBadges
untappd.userBadges(goodbadResults("userBadges"),{USERNAME: sampleUser});
// Test userDistinctBeers
untappd.userDistinctBeers(goodbadResults("userDistinctBeers"),{USERNAME: sampleUser});
// Test brewerInfo
untappd.breweryInfo(goodbadResults("brewerInfo"),{BREWERY_ID:brewery_id});
// Test beerInfo
untappd.beerInfo(goodbadResults("beerInfo"),{BID:beer_id});
// Test venueInfo
untappd.venueInfo(goodbadResults("venueInfo"),{VENUE_ID:venue_id});
// Test Beer Search
untappd.beerSearch(goodbadResults("searchBeer"),{q:"Stout"});
// Test Brewery Search
untappd.brewerySearch(goodbadResults("searchBrewery"),{q:"Stone"});
// Test foursquareVenueLookup
untappd.foursquareVenueLookup(goodbadResults("foursquareVenueLookup"),{VENUE_ID:foursquare_id});