-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib): Move terms function to proper place
This 'view' was not really a view, because it did not produce results based on the variable store. Instead it simply took parameters and returned an object that was a valid terms query. This is a good feature to have, but it should be internal to this library only.
- Loading branch information
1 parent
b847841
commit b6748c8
Showing
5 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const terms = require('../../../lib/leaf/terms'); | ||
|
||
module.exports.tests = {}; | ||
|
||
module.exports.tests.terms = function(test, common) { | ||
test('null returned if property missing', function(t) { | ||
const query = terms(); | ||
|
||
t.equal(null, query, 'null query returned'); | ||
t.end(); | ||
}); | ||
|
||
test('null returned if value missing', function(t) { | ||
const query = terms('theproperty'); | ||
|
||
t.equal(null, query, 'null query returned'); | ||
t.end(); | ||
}); | ||
|
||
test('terms query returned with property and value', function(t) { | ||
const query = terms('theproperty', 'thevalue'); | ||
|
||
const expected = { | ||
terms: { | ||
theproperty: 'thevalue' | ||
} | ||
}; | ||
|
||
t.deepEqual(query, expected, 'valid terms query'); | ||
t.end(); | ||
}); | ||
}; | ||
|
||
module.exports.all = function (tape, common) { | ||
function test(name, testFunction) { | ||
return tape('lib/leaf/terms ' + name, testFunction); | ||
} | ||
for( var testCase in module.exports.tests ){ | ||
module.exports.tests[testCase](test, common); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters