@@ -584,30 +584,58 @@ describe('ConstructorIO - Utils - Helpers', () => {
584584 } ) ;
585585
586586 describe ( 'addHTTPSToString' , ( ) => {
587- it ( 'Should return the url without any modification' , ( ) => {
588- const testUrl = 'https://www.constructor.io' ;
587+ describe ( 'when allowHttp is not given' , ( ) => {
588+ it ( 'Should return the url without any modification' , ( ) => {
589+ const testUrl = 'https://www.constructor.io' ;
589590
590- expect ( addHTTPSToString ( testUrl ) ) . to . equal ( testUrl ) ;
591- } ) ;
591+ expect ( addHTTPSToString ( testUrl ) ) . to . equal ( testUrl ) ;
592+ } ) ;
592593
593- it ( 'Should return url with no protocol with https at the beginning' , ( ) => {
594- const testUrl = 'www.constructor.io' ;
595- const expectedUrl = 'https://www.constructor.io' ;
594+ it ( 'Should return url with no protocol with https at the beginning' , ( ) => {
595+ const testUrl = 'www.constructor.io' ;
596+ const expectedUrl = 'https://www.constructor.io' ;
596597
597- expect ( addHTTPSToString ( testUrl ) ) . to . equal ( expectedUrl ) ;
598- } ) ;
598+ expect ( addHTTPSToString ( testUrl ) ) . to . equal ( expectedUrl ) ;
599+ } ) ;
599600
600- it ( 'Should return url with an http protocol with https at the beginning' , ( ) => {
601- const testUrl = 'http://www.constructor.io' ;
602- const expectedUrl = 'https://www.constructor.io' ;
601+ it ( 'Should return url with an http protocol with https at the beginning' , ( ) => {
602+ const testUrl = 'http://www.constructor.io' ;
603+ const expectedUrl = 'https://www.constructor.io' ;
603604
604- expect ( addHTTPSToString ( testUrl ) ) . to . equal ( expectedUrl ) ;
605+ expect ( addHTTPSToString ( testUrl ) ) . to . equal ( expectedUrl ) ;
606+ } ) ;
607+
608+ it ( 'Should return null if param is not a string' , ( ) => {
609+ const testUrl = { } ;
610+
611+ expect ( addHTTPSToString ( testUrl ) ) . to . equal ( null ) ;
612+ } ) ;
605613 } ) ;
614+ describe ( 'when allowHttp is not given' , ( ) => {
615+ it ( 'Should return the url without any modification' , ( ) => {
616+ const testUrl = 'https://www.constructor.io' ;
606617
607- it ( 'Should return null if param is not a string' , ( ) => {
608- const testUrl = { } ;
618+ expect ( addHTTPSToString ( testUrl , true ) ) . to . equal ( testUrl ) ;
619+ } ) ;
609620
610- expect ( addHTTPSToString ( testUrl ) ) . to . equal ( null ) ;
621+ it ( 'Should return url with no protocol with https at the beginning' , ( ) => {
622+ const testUrl = 'www.constructor.io' ;
623+ const expectedUrl = 'https://www.constructor.io' ;
624+
625+ expect ( addHTTPSToString ( testUrl , true ) ) . to . equal ( expectedUrl ) ;
626+ } ) ;
627+
628+ it ( 'Should return url with an http protocol without any modification' , ( ) => {
629+ const testUrl = 'http://localhost:8080' ;
630+
631+ expect ( addHTTPSToString ( testUrl , true ) ) . to . equal ( testUrl ) ;
632+ } ) ;
633+
634+ it ( 'Should return null if param is not a string' , ( ) => {
635+ const testUrl = { } ;
636+
637+ expect ( addHTTPSToString ( testUrl , true ) ) . to . equal ( null ) ;
638+ } ) ;
611639 } ) ;
612640 } ) ;
613641
0 commit comments