Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Add id for better result ranking, see #1
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbayerlein committed Mar 20, 2017
1 parent 80d668a commit 93b11fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions __tests__/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('github.js', () => {
let cache;

const mockResult = require('../__mocks__/result.json').items.map(repository => ({
id: repository.full_name,
title: repository.full_name,
value: repository.html_url,
subtitle: repository.description,
Expand Down Expand Up @@ -58,6 +59,13 @@ describe('github.js', () => {
})
));

test('returns the expected id', () => (
github.search('honeycomb')
.then((repositories) => {
expect(repositories[0].id).toBe('altamiracorp/honeycomb');
})
));

test('returns the expected title', () => (
github.search('honeycomb')
.then((repositories) => {
Expand Down Expand Up @@ -170,6 +178,12 @@ describe('github.js', () => {
})
));

test('returns an object with a id', () => (
searchResult.then((repositories) => {
expect(repositories[0].id).toBeDefined();
})
));

test('returns an object with a title', () => (
searchResult.then((repositories) => {
expect(repositories[0].title).toBeDefined();
Expand Down
1 change: 1 addition & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports.search = (query) => {
got(URL, options)
.then((response) => {
const data = response.body.items.map(repository => ({
id: repository.full_name,
title: repository.full_name,
value: repository.html_url,
subtitle: repository.description,
Expand Down

1 comment on commit 93b11fe

@bayleedev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.