-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript definition, update dependencies (#4)
- Loading branch information
1 parent
32bb674
commit de325d8
Showing
7 changed files
with
34 additions
and
17 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' |
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,7 @@ | ||
/** | ||
* Get the email of an npm user. | ||
* | ||
* @param username - npm username to look up. | ||
* @returns A promise for the user's email address. | ||
*/ | ||
export default function npmEmail(username: string): Promise<string>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {expectType} from 'tsd-check'; | ||
import npmEmail from '.'; | ||
|
||
expectType<Promise<string>>(npmEmail('sindresorhus')); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import test from 'ava'; | ||
import m from '.'; | ||
import npmEmail from '.'; | ||
|
||
test('invalid input', async t => { | ||
await t.throws(m(1), 'Username required'); | ||
await t.throwsAsync(npmEmail(1), 'Username required'); | ||
}); | ||
|
||
test('unknown username', async t => { | ||
const randomName = `asdasfgrgafadsgaf${Math.random().toString().slice(2)}`; | ||
await t.throws(m(randomName), `User ${randomName} doesn't exist`); | ||
await t.throwsAsync(npmEmail(randomName), `User ${randomName} doesn't exist`); | ||
}); | ||
|
||
test('valid username', async t => { | ||
t.is(await m('sindresorhus'), 'sindresorhus@gmail.com'); | ||
t.is(await npmEmail('sindresorhus'), 'sindresorhus@gmail.com'); | ||
}); | ||
|
||
test('valid username with special character', async t => { | ||
t.is(await m(`lukeramsden'`), 'lukeramsden8@gmail.com'); | ||
t.is(await npmEmail('lukeramsden\''), 'lukeramsden8@gmail.com'); | ||
}); |