-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to pass multiple keywords #13
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,17 @@ test('npmKeyword.count()', async t => { | |
t.is(typeof cnt1, 'number'); | ||
t.is(cnt2, 0); | ||
}); | ||
|
||
test('npmKeyword.count() using an array of keywords', async t => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would love to test the part of the URL separately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean you want to test https://github.com/mischah/npm-keyword/blob/ebad0e848901f4d5495e9d605ffbfafd3ae6f528/index.js#L16 separately? For what purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the testing the correct URL creation independent of the API and the response. What do you mean? |
||
const cnt1 = await m.count('gulpplugin'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
const cnt2 = await m.count(['gulpplugin', 'sass', 'css']); | ||
|
||
t.true(cnt2 > 0); | ||
t.true(cnt2 < cnt1); | ||
}); | ||
|
||
test('npmKeyword.count() using wrong type for keywords parameter', async t => { | ||
const error = await t.throws(m.count({keyword: 'gulpplugin'})); | ||
|
||
t.is(error.message, 'Keyword must be either a string or an array of strings'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to »clever«? 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing it? From the docs:
So that should be
+
=>,
, but have you tested whether it supports encoded comma or not?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs are
wrongmisleading (Going to create a PR to fix thisSee https://github.com/npm/registry/pull/235).Combining keywords with
,
acts like a||
while combining them with+
acts like a&&
.So we need to use a
+
in our use case.Compare the following:
keywords:yeoman-generator ➡️
"total": 6994
keywords:yeoman-generator,baumeister ➡️
"total": 6994
keywords:yeoman-generator+baumeister ➡️
"total": 1
keywords:yeoman-generator,-baumeister ➡️
"total": 6993