mirror of
https://github.com/krisk/Fuse.git
synced 2026-01-25 16:43:11 +00:00
Test recursion into arrays
This commit is contained in:
parent
5d650eb0b0
commit
82878ce14e
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user