Test recursion into arrays

This commit is contained in:
Matthew Dapena-Tretter 2014-09-08 15:44:34 -04:00
parent 5d650eb0b0
commit 82878ce14e

View File

@ -339,4 +339,46 @@ vows.describe('Include both ID and score in results list').addBatch({
}
}
}
}).export(module);
}).export(module);
vows.describe('Recurse into arrays').addBatch({
'Options:': {
topic: function() {
var books = [{
"ISBN": "0765348276",
"title": "Old Man's War",
"author": "John Scalzi",
"tags": ["fiction"]
}, {
"ISBN": "0312696957",
"title": "The Lock Artist",
"author": "Steve Hamilton",
"tags": ["fiction"]
}, {
"ISBN": "0321784421",
"title": "HTML5",
"author": "Remy Sharp",
"tags": ["nonfiction"]
}];
var options = {
keys: ["tags"],
id: "ISBN",
threshold: 0
}
var fuse = new Fuse(books, options)
return fuse;
},
'When searching for the tag "nonfiction"': {
topic: function(fuse) {
var result = fuse.search("nonfiction");
return result;
},
'we get a list containing 1 item': function(result) {
assert.equal(result.length, 1);
},
'whose value is the ISBN of the book': function(result) {
assert.equal(result[0], '0321784421');
}
}
}
}).export(module);