Permalink
Browse files

Update Trakt's API search call

  • Loading branch information...
tegon committed Mar 11, 2017
1 parent 5d0bc7e commit 3d9ddb053fdf2371c9bc1c7d0097aa4c0980e681
@@ -11,7 +11,7 @@ function Search(options) {
Search.prototype = {
getUrl: function() {
return this.url + '?type=' + this.item.type + '&query=' + encodeURIComponent(this.item.title);
return this.url + '/' + this.item.type + '?query=' + encodeURIComponent(this.item.title);
},
getEpisodeUrl: function(slug) {
@@ -33,11 +33,10 @@ export default class ActivityListItem extends React.Component {
let netflixTitle = netflix.epTitle ? `${netflix.title}: ${netflix.epTitle}` : netflix.title;
let netflixUrl = `https://www.netflix.com/watch/${netflix.id}`;
let trakt = activity.trakt;
let traktDate, traktImage, traktUrl, traktTitle;
let traktDate, traktUrl, traktTitle;
if (trakt) {
traktDate = trakt.date ? trakt.date.format('MMMM Do YYYY, h:mm:ss a') : '-';
traktImage = trakt.images.poster ? trakt.images.poster : trakt.images.screenshot;
traktUrl = trakt.season ? `https://trakt.tv/shows/${trakt.show.ids.slug}/seasons/${trakt.season}/episodes/${trakt.number}` : `https://trakt.tv/movies/${trakt.ids.slug}`;
traktTitle = trakt.show ? `${trakt.show.title}: ${trakt.title}` : trakt.title;
}
@@ -31,8 +31,8 @@ describe('Search', function() {
});
it('getUrl function', function() {
expect(movieSearch.getUrl()).toBe(Settings.apiUri + '/search?type=' + rocky.type +
'&query=' + rocky.title);
expect(movieSearch.getUrl()).toBe(Settings.apiUri + '/search/' + rocky.type +
'?query=' + rocky.title);
});
it('getEpisodeUrl uses episode number when item has an episode number', function() {
@@ -62,7 +62,7 @@ describe('Search', function() {
'{ "errors": "Bad Request" }');
expect(error.callCount).toBe(1);
expect(error.getCall(0).args).toEqual([400, '{ "errors": "Bad Request" }',
{ method: 'GET', url: 'https://api.trakt.tv/search?type=movie&query=Rocky', params: undefined }]);
{ method: 'GET', url: 'https://api.trakt.tv/search/movie?query=Rocky', params: undefined }]);
});
it('findEpisode returns first search result', function() {
@@ -132,7 +132,7 @@ describe('Search', function() {
'{ "errors": "Bad Request" }');
expect(error.callCount).toBe(1);
expect(error.getCall(0).args).toEqual([400, '{ "errors": "Bad Request" }',
{ url: 'https://api.trakt.tv/search?type=show&query=Mad%20Men', method: 'GET', params: undefined }]);
{ url: 'https://api.trakt.tv/search/show?query=Mad%20Men', method: 'GET', params: undefined }]);
});
it('when item type is show, find calls findEpisode', function() {

0 comments on commit 3d9ddb0

Please sign in to comment.