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

Commit

Permalink
Merge pull request #9250 from brave/custom-title-suggestions
Browse files Browse the repository at this point in the history
Allow suggestions from bookmark custom titles
  • Loading branch information
bsclifton committed Jun 4, 2017
1 parent 2e14350 commit 6b8cc7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/common/lib/siteSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ const tokenizeInput = (data) => {
return []
}
url = data.location
if (data.customTitle) {
parts = getPartsFromNonUrlInput(data.customTitle)
}
if (data.title) {
parts = getPartsFromNonUrlInput(data.title)
parts = parts.concat(getPartsFromNonUrlInput(data.title))
}
if (data.tags) {
parts = parts.concat(data.tags.map(getTagToken))
Expand Down
16 changes: 11 additions & 5 deletions test/unit/app/common/lib/siteSuggestionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const site3 = {
const site4 = {
location: 'https://www.designers.com/brad',
title: 'Brad Saves The World!',
count: 50
count: 50,
customTitle: 'brad-heart-composite'
}

// Same as site4 but added after in init, should be ignored.
Expand Down Expand Up @@ -149,6 +150,9 @@ describe('siteSuggestions lib', function () {
it('can query on title', function (cb) {
checkResult('back', [site2], cb)
})
it('can query on customTitle', function (cb) {
checkResult('heart-comp', [site4], cb)
})
it('can query on multiple tokens in different order', function (cb) {
checkResult('back really', [site2], cb)
})
Expand Down Expand Up @@ -337,11 +341,13 @@ describe('siteSuggestions lib', function () {
checkResult('slack', [{ location: 'https://slack.com' }], cb)
})
it('adding twice results in 1 result only with latest results', function (cb) {
add({
const newSite = {
location: 'https://slack.com',
count: 30
})
checkResult('slack', [{ location: 'https://slack.com', count: 30 }], cb)
count: 30,
customTitle: 'SlickSlack'
}
add(newSite)
checkResult('slack', [newSite], cb)
})
it('can add simple strings', function (cb) {
add({
Expand Down

0 comments on commit 6b8cc7b

Please sign in to comment.