@@ -251,4 +251,55 @@ describe('LinkService', () => {
251251 } ) ;
252252 } ) ;
253253
254+ describe ( 'User Functions' , ( ) => {
255+ fdescribe ( 'isLinkInternal' , ( ) => {
256+ it ( 'should return true for internal link starting with "/"' , ( ) => {
257+ result = service . isLinkInternal ( '/my-link' , 'https://currentdomain' ) ;
258+ expect ( result ) . toBe ( true ) ;
259+ } ) ;
260+
261+ it ( 'should return true for internal link starting with currentURL' , ( ) => {
262+ result = service . isLinkInternal ( 'https://currentdomain/my-link' , 'https://currentdomain' ) ;
263+ expect ( result ) . toBe ( true ) ;
264+ } ) ;
265+
266+ it ( 'should return true for internal link starting with "currentdomain"' , ( ) => {
267+ result = service . isLinkInternal ( 'currentdomain/my-link' , 'https://currentdomain' ) ;
268+ expect ( result ) . toBe ( true ) ;
269+ } ) ;
270+
271+ it ( 'should return false for external link' , ( ) => {
272+ result = service . isLinkInternal ( 'https://externaldomain/my-link' , 'https://currentdomain' ) ;
273+ expect ( result ) . toBe ( false ) ;
274+ } ) ;
275+
276+ it ( 'should return true for internal link link without leading "/"' , ( ) => {
277+ result = service . isLinkInternal ( 'my-link' , 'https://currentdomain' ) ;
278+ expect ( result ) . toBe ( true ) ;
279+ } ) ;
280+ } ) ;
281+
282+ fdescribe ( 'transformInternalLink' , ( ) => {
283+ it ( 'should transform internal link by removing currentURL' , ( ) => {
284+ result = service . transformInternalLink ( 'https://currentdomain/my-link' , 'https://currentdomain' ) ;
285+ expect ( result ) . toBe ( '/my-link' ) ;
286+ } ) ;
287+
288+ it ( 'should transform internal link by adding leading "/" if missing' , ( ) => {
289+ result = service . transformInternalLink ( 'currentdomain/my-link' , 'https://currentdomain' ) ;
290+ expect ( result ) . toBe ( '/my-link' ) ;
291+ } ) ;
292+
293+ it ( 'should return unchanged link for external link' , ( ) => {
294+ result = service . transformInternalLink ( 'https://externalDomain/my-link' , 'https://currentdomain' ) ;
295+ expect ( result ) . toBe ( 'https://externalDomain/my-link' ) ;
296+ } ) ;
297+
298+ it ( 'should return unchanged link for internal link with leading "/"' , ( ) => {
299+ result = service . transformInternalLink ( '/my-link' , 'https://currentdomain' ) ;
300+ expect ( result ) . toBe ( '/my-link' ) ;
301+ } ) ;
302+ } ) ;
303+ } ) ;
304+
254305} ) ;
0 commit comments