Skip to content

Commit

Permalink
Both testing query and index as not an arraBoth testing query and ind…
Browse files Browse the repository at this point in the history
…ex as not an arrayy
  • Loading branch information
eklem committed Jun 16, 2020
1 parent 9c523f6 commit 6052dc6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const test = require('tape')
const lvm = require('../index.js')
const index = ['return', 'all', 'word', 'matches', 'between', 'two', 'arrays', 'within', 'given', 'levenshtein', 'distance', 'intended', 'use', 'is', 'to', 'words', 'in', 'a', 'query', 'that', 'has', 'an', 'index', 'good', 'for', 'autocomplete', 'type', 'functionality,', 'and', 'some', 'cases', 'also', 'searching']
const query = ['qvery', 'words', 'levensthein']
const queryNotArray = 'some string'
const notAnArray = 'some string'

test('match without setting distance, setting custom distance and inputting a string istead of an array', function (t) {
t.plan(3)
t.plan(4)

// Standard distance
let matched = lvm.levenMatch(query, index)
Expand All @@ -16,6 +16,10 @@ test('match without setting distance, setting custom distance and inputting a st
t.deepEqual(matched, [['query'], ['word', 'words'], ['levenshtein']])

// query input not an array
matched = lvm.levenMatch(queryNotArray, index)
matched = lvm.levenMatch(notAnArray, index)
t.deepEqual(matched, undefined)

// query input not an array
matched = lvm.levenMatch(query, notAnArray)
t.deepEqual(matched, undefined)
})

0 comments on commit 6052dc6

Please sign in to comment.