11import test from 'ava'
22import m from './'
33
4- test ( 'expected a string' , t => {
5- t . throws ( ( ) => m ( ) , 'Expected a string, not undefined' )
6- t . throws ( ( ) => m ( [ ] ) , 'Expected a string, not object' )
7- t . throws ( ( ) => m ( { } ) , 'Expected a string, not object' )
4+ test ( 'other types must return false' , t => {
5+ t . false ( m ( ) )
6+ t . false ( m ( '' ) )
7+ t . false ( m ( undefined ) )
8+ t . false ( m ( 123 ) )
9+ t . false ( m ( true ) )
10+ t . false ( m ( false ) )
11+ t . false ( m ( ( ) => { } ) )
12+ t . false ( m ( [ ] ) )
13+ t . false ( m ( { } ) )
14+ t . false ( m ( null ) )
15+ t . false ( m ( Symbol ( '' ) ) )
816} )
917
1018test ( 'check url protocol without slashes' , t => {
@@ -18,6 +26,8 @@ test('check url protocol without slashes', t => {
1826 t . true ( m ( 'skype:login?chat' ) )
1927 t . true ( m ( 'smsto:8881234567?body=hello!' ) )
2028 t . true ( m ( 'bitcoin:19UBzu6Bt4bsx7eTb7eryFWKJ7TF8Bwtnf' ) )
29+ t . true ( m ( 'virtual:some/foo//bar' ) )
30+ t . true ( m ( 'virtual:duplicate-virtual://foo-bar.com' ) )
2131} )
2232
2333test ( 'check url protocol with slashes' , t => {
@@ -28,6 +38,8 @@ test('check url protocol with slashes', t => {
2838 t . false ( m ( 'http://admin:pass@site.com:3000/a/b/./c' ) )
2939 t . false ( m ( 'http://admin:pass@site.com:3000/a/b/../c' ) )
3040 t . false ( m ( 'http://admin:pass@site.com:3000/a/b/../c/d.js' ) )
41+ t . false ( m ( 'http://admin:pass@site.com/foo//bar' ) )
42+ t . false ( m ( 'http://admin:pass@site.com/foo/http://test.com' ) )
3143 t . false ( m ( '//site.com' ) )
3244 t . false ( m ( '//site.com:3000' ) )
3345 t . false ( m ( '//site.com:3000/a' ) )
0 commit comments