@@ -51,6 +51,57 @@ describe('paste-markdown', function () {
51
51
assert . equal ( textarea . value , 'The examples can be found [here](https://www.github.com/).' )
52
52
} )
53
53
54
+ it ( 'creates a markdown link for longer urls' , function ( ) {
55
+ // eslint-disable-next-line i18n-text/no-en
56
+ textarea . value = 'The examples can be found here.'
57
+ textarea . setSelectionRange ( 26 , 30 )
58
+ paste ( textarea , { 'text/plain' : 'https://www.github.com/path_to/something-different/too' } )
59
+ assert . equal (
60
+ textarea . value ,
61
+ 'The examples can be found [here](https://www.github.com/path_to/something-different/too).'
62
+ )
63
+ } )
64
+
65
+ it ( 'creates a markdown link with query string' , function ( ) {
66
+ // eslint-disable-next-line i18n-text/no-en
67
+ textarea . value = 'The examples can be found here.'
68
+ textarea . setSelectionRange ( 26 , 30 )
69
+ paste ( textarea , { 'text/plain' : 'https://www.github.com/path/to/something?query=true' } )
70
+ assert . equal (
71
+ textarea . value ,
72
+ 'The examples can be found [here](https://www.github.com/path/to/something?query=true).'
73
+ )
74
+ } )
75
+
76
+ it ( 'creates a markdown link with hash params' , function ( ) {
77
+ // eslint-disable-next-line i18n-text/no-en
78
+ textarea . value = 'The examples can be found here.'
79
+ textarea . setSelectionRange ( 26 , 30 )
80
+ paste ( textarea , { 'text/plain' : 'https://www.github.com/path/to/something#section' } )
81
+ assert . equal (
82
+ textarea . value ,
83
+ 'The examples can be found [here](https://www.github.com/path/to/something#section).'
84
+ )
85
+ } )
86
+
87
+ it ( 'creates a link for http urls' , function ( ) {
88
+ // eslint-disable-next-line i18n-text/no-en
89
+ textarea . value = 'Look over here please'
90
+ textarea . setSelectionRange ( 10 , 14 )
91
+ const url = 'http://someotherdomain.org/another/thing'
92
+ paste ( textarea , { 'text/plain' : url } )
93
+ assert . equal ( textarea . value , `Look over [here](${ url } ) please` )
94
+ } )
95
+
96
+ it ( 'creates a link when copied content includes spaces and a newline' , ( ) => {
97
+ // eslint-disable-next-line i18n-text/no-en
98
+ textarea . value = 'Look over here please'
99
+ textarea . setSelectionRange ( 10 , 14 )
100
+ const url = 'http://someotherdomain.org/another/thing \n'
101
+ paste ( textarea , { 'text/plain' : url } )
102
+ assert . equal ( textarea . value , `Look over [here](${ url . trim ( ) } ) please` )
103
+ } )
104
+
54
105
it ( "doesn't paste a markdown URL when pasting over a selected URL" , function ( ) {
55
106
// eslint-disable-next-line i18n-text/no-en
56
107
textarea . value = 'The examples can be found here: https://docs.github.com'
0 commit comments