1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Merge pull request #1701 from bimlas/fix-filter-by-tag-in-search-entry

Fix tag filtering in search entry
This commit is contained in:
Junyoung Choi (Sai)
2018-04-10 19:59:20 +09:00
committed by GitHub
2 changed files with 22 additions and 26 deletions

View File

@@ -20,18 +20,25 @@ test.before(t => {
notes = [note1, note2, note3]
})
test('it can find notes by tags or words', t => {
test('it can find notes by tags and words', t => {
// [input, expected content (Array)]
const testCases = [
const testWithTags = [
['#tag1', [note1.content, note2.content, note3.content]],
['#tag1 #tag2', [note2.content]],
['#tag2 #tag1', [note2.content]],
['#tag1 #tag2 #tag3', []],
['content1', [note1.content, note2.content]],
['content1 content2', [note2.content]],
['content1 content2 content3', []],
['#content4', [note3.content]]
['#content4', [note3.content]],
['#tag2 content1', [note2.content]],
['content1 #tag2', [note2.content]]
]
const testWithTagsWithoutHash = testWithTags.map(function (testCase) {
return [testCase[0].replace(/#/g, ''), testCase[1]]
})
const testCases = testWithTags.concat(testWithTagsWithoutHash)
testCases.forEach((testCase) => {
const [input, expectedContents] = testCase
const results = searchFromNotes(notes, input)