Skip to content

Commit 3980c71

Browse files
committed
New endpoints: spellcheck, trending_searches, and related_searches.
1 parent 28205f4 commit 3980c71

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

examples/sample.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ client.search({
4141
// console.log(error);
4242
// });
4343

44+
// client.spellcheck({
45+
// q: 'evergrand stok',
46+
// }).then((response) => {
47+
// console.log(response.data);
48+
// }).catch((error) => {
49+
// console.log(error);
50+
// });
51+
52+
// client.fetchRelatedSearches({
53+
// q: 'evergrande',
54+
// }).then((response) => {
55+
// console.log(response.data);
56+
// }).catch((error) => {
57+
// console.log(error);
58+
// });
59+
60+
// client.fetchTrendingSearches().then((response) => {
61+
// console.log(response.data);
62+
// }).catch((error) => {
63+
// console.log(error);
64+
// });
65+
4466
// client.fetchBestPodcasts({
4567
// }).then((response) => {
4668
// console.log(response.data);

examples/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ follow-redirects@^1.14.0:
2525
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
2626

2727
podcast-api@../:
28-
version "1.0.8"
28+
version "1.0.9"
2929
dependencies:
3030
axios "^0.21.1"
3131
query-string "^7.0.1"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "podcast-api",
3-
"version": "1.0.9",
3+
"version": "1.1.0",
44
"description": "JavaScript bindings for the Listen Notes Podcast API",
55
"main": "src/PodcastApiClient.js",
66
"scripts": {

src/PodcastApiClient.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const Client = (config = {}) => {
2626

2727
this.typeahead = (params) => this.httpClient.get('/typeahead', { params });
2828

29+
this.spellcheck = (params) => this.httpClient.get('/spellcheck', { params });
30+
31+
this.fetchRelatedSearches = (params) => this.httpClient.get('/related_searches', { params });
32+
33+
this.fetchTrendingSearches = (params) => this.httpClient.get('/trending_searches', { params });
34+
2935
this.fetchBestPodcasts = (params) => this.httpClient.get('/best_podcasts', { params });
3036

3137
this.fetchPodcastById = (params) => {

tests/PodcastApiTest.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,47 @@ test('Test typeahead with mock', () => {
5757
});
5858
});
5959

60+
test('Test spellcheck with mock', () => {
61+
const client = Client();
62+
const term = 'evergrand stok';
63+
return client.spellcheck({
64+
q: term,
65+
}).then((response) => {
66+
expect(response.config.params.q).toBe(term);
67+
expect(response.config.url).toBe('/spellcheck');
68+
expect(response.config.method).toBe('get');
69+
expect(response.data.tokens.length > 0).toBe(true);
70+
}).catch(() => {
71+
fail('Failed!');
72+
});
73+
});
74+
75+
test('Test related searches with mock', () => {
76+
const client = Client();
77+
const term = 'evergrande';
78+
return client.fetchRelatedSearches({
79+
q: term,
80+
}).then((response) => {
81+
expect(response.config.params.q).toBe(term);
82+
expect(response.config.url).toBe('/related_searches');
83+
expect(response.config.method).toBe('get');
84+
expect(response.data.terms.length > 0).toBe(true);
85+
}).catch((e) => {
86+
fail('Failed!');
87+
});
88+
});
89+
90+
test('Test trending searches with mock', () => {
91+
const client = Client();
92+
return client.fetchTrendingSearches().then((response) => {
93+
expect(response.config.url).toBe('/trending_searches');
94+
expect(response.config.method).toBe('get');
95+
expect(response.data.terms.length > 0).toBe(true);
96+
}).catch(() => {
97+
fail('Failed!');
98+
});
99+
});
100+
60101
test('Test fetchBestPodcasts with mock', () => {
61102
const client = Client();
62103
const genreId = 123;

0 commit comments

Comments
 (0)