This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathindex.js
61 lines (55 loc) · 1.52 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
import test from 'blue-tape';
import Yelp from '../src/';
const opts = {
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
token: process.env.TOKEN,
token_secret: process.env.TOKEN_SECRET,
};
const yelp = new Yelp(opts);
test('yelp search', (t) => {
return yelp.search({
term: 'food',
location: 'Montreal',
}).then((data) => {
t.equal(typeof data.region, 'object');
t.equal(typeof data.total, 'number');
t.ok(Array.isArray(data.businesses), 'businesses is array');
})
.catch((err) => {
t.error(err);
});
});
test('yelp business', (t) => {
return yelp.business('yelp-san-francisco').then((data) => {
t.equal(data.is_claimed, true);
t.equal(typeof data.rating, 'number');
t.equal(typeof data.mobile_url, 'string');
t.ok(Array.isArray(data.categories), 'categories is array');
t.ok(Array.isArray(data.reviews), 'reviews is array');
})
.catch((err) => {
t.error(err);
});
});
test('yelp phoneSearch', (t) => {
return yelp.phoneSearch({ phone: '+15555555555' }).then((data) => {
t.equal(typeof data.total, 'number');
t.ok(Array.isArray(data.businesses), 'businesses is array');
})
.catch((err) => {
t.error(err);
});
});
test('yelp - callback', (t) => {
t.plan(4);
yelp.search({
term: 'food',
location: 'Montreal',
}, (err, data) => {
t.error(err);
t.equal(typeof data.region, 'object');
t.equal(typeof data.total, 'number');
t.ok(Array.isArray(data.businesses), 'businesses is array');
});
});