@@ -32,4 +32,34 @@ describe('Link', () => {
32
32
const result = shallow ( < Link decoratedText = "https://www.draft-js-plugins.com/" /> ) ;
33
33
expect ( result ) . to . have . prop ( 'href' ) . to . contain ( 'https://www.draft-js-plugins.com/' ) ;
34
34
} ) ;
35
+
36
+ it ( 'applies http prefix when none is supplied' , ( ) => {
37
+ const result = shallow ( < Link decoratedText = "draft-js-plugins.com/" /> ) ;
38
+ expect ( result ) . to . have . prop ( 'href' ) . to . contain ( 'http://draft-js-plugins.com/' ) ;
39
+ } ) ;
40
+
41
+ it ( 'does not apply a prefix when one is already supplied' , ( ) => {
42
+ const result = shallow ( < Link decoratedText = "ftp://draft-js-plugins.com/" /> ) ;
43
+ expect ( result ) . to . have . prop ( 'href' ) . to . contain ( 'ftp://draft-js-plugins.com/' ) ;
44
+ } ) ;
45
+
46
+ it ( 'generates correct href to localhost with port' , ( ) => {
47
+ const result = shallow ( < Link decoratedText = "http://localhost:8000" /> ) ;
48
+ expect ( result ) . to . have . prop ( 'href' ) . to . contain ( 'http://localhost:8000' ) ;
49
+ } ) ;
50
+
51
+ it ( 'generates mailto href when supplied with email' , ( ) => {
52
+ const result = shallow ( < Link decoratedText = "name@example.com" /> ) ;
53
+ expect ( result ) . to . have . prop ( 'href' ) . to . contain ( 'mailto:name@example.com' ) ;
54
+ } ) ;
55
+
56
+ it ( 'uses _self as the default target value' , ( ) => {
57
+ const result = shallow ( < Link /> ) ;
58
+ expect ( result ) . to . have . prop ( 'target' ) . to . contain ( '_self' ) ;
59
+ } ) ;
60
+
61
+ it ( 'applies custom target value' , ( ) => {
62
+ const result = shallow ( < Link target = "_blank" /> ) ;
63
+ expect ( result ) . to . have . prop ( 'target' ) . to . contain ( '_blank' ) ;
64
+ } ) ;
35
65
} ) ;
0 commit comments