4949 assert . strictEqual ( data , '<p>set a <a href="http://test.com" target="_blank">http://test.com</a> and then convert it to a link.</p>' ) ;
5050 } ) ;
5151
52+ it ( 'should add default protocol when creating a link' , function ( ) {
53+ var link = new CKEDITOR . Link ( this . nativeEditor ) ;
54+
55+ bender . tools . selection . setWithHtml ( this . nativeEditor , 'set a {selection} and then convert it to a link.' ) ;
56+
57+ link . create ( 'test.com' , {
58+ target : '_blank'
59+ } ) ;
60+
61+ var data = bender . tools . getData ( this . nativeEditor , {
62+ fixHtml : true ,
63+ compatHtml : true
64+ } ) ;
65+
66+ assert . strictEqual ( data , '<p>set a <a href="http://test.com" target="_blank">selection</a> and then convert it to a link.</p>' ) ;
67+ } ) ;
68+
69+ it ( 'should not add default protocol if it already has one' , function ( ) {
70+ var link = new CKEDITOR . Link ( this . nativeEditor ) ;
71+
72+ bender . tools . selection . setWithHtml ( this . nativeEditor , 'set a {selection} and then convert it to a link.' ) ;
73+
74+ link . create ( '//test.com' , {
75+ target : '_blank'
76+ } ) ;
77+
78+ var data = bender . tools . getData ( this . nativeEditor , {
79+ fixHtml : true ,
80+ compatHtml : true
81+ } ) ;
82+
83+ assert . strictEqual ( data , '<p>set a <a href="//test.com" target="_blank">selection</a> and then convert it to a link.</p>' ) ;
84+ } ) ;
85+
5286 it ( 'should retrieve a link from a selection' , function ( ) {
5387 var link = new CKEDITOR . Link ( this . nativeEditor ) ;
5488
148182
149183 assert . strictEqual ( data , '<p>update the url of a <a href="http://new.com" target="_blank">link</a>.</p>' ) ;
150184 } ) ;
185+
186+ it ( 'should not add default protocol when updating a link' , function ( ) {
187+ var link = new CKEDITOR . Link ( this . nativeEditor ) ;
188+
189+ bender . tools . selection . setWithHtml ( this . nativeEditor , '<p>update the URL of a {<a href="http://test.com" target="_blank">link</a>}.</p>' ) ;
190+
191+ var linkEl = link . getFromSelection ( ) ;
192+ assert . ok ( linkEl ) ;
193+
194+ link . update ( 'new.com' , linkEl ) ;
195+
196+ var data = bender . tools . getData ( this . nativeEditor , {
197+ fixHtml : true ,
198+ compatHtml : true
199+ } ) ;
200+
201+ assert . strictEqual ( data , '<p>update the url of a <a href="new.com" target="_blank">link</a>.</p>' ) ;
202+ } ) ;
151203 } ) ;
152204} ( ) ) ;
0 commit comments