@@ -39,6 +39,28 @@ describe('useCalendarLinks', () => {
3939 } )
4040 expect ( googleUrl . value ) . toContain ( 'Event' )
4141 } )
42+
43+ it ( 'includes url in details when no description' , ( ) => {
44+ const { googleUrl } = useCalendarLinks ( {
45+ title : ref ( 'Test Event' ) ,
46+ startTs : ref ( START_TS ) ,
47+ endTs : ref ( null ) ,
48+ url : ref ( 'https://example.com' ) ,
49+ } )
50+ expect ( googleUrl . value ) . toContain ( 'example.com' )
51+ } )
52+
53+ it ( 'prepends url before description in details' , ( ) => {
54+ const { googleUrl } = useCalendarLinks ( {
55+ title : ref ( 'Test Event' ) ,
56+ startTs : ref ( START_TS ) ,
57+ endTs : ref ( null ) ,
58+ description : ref ( 'A description' ) ,
59+ url : ref ( 'https://example.com' ) ,
60+ } )
61+ const details = new URL ( googleUrl . value ) . searchParams . get ( 'details' ) !
62+ expect ( details . indexOf ( 'example.com' ) ) . toBeLessThan ( details . indexOf ( 'A description' ) )
63+ } )
4264 } )
4365
4466 describe ( 'Outlook.com URL' , ( ) => {
@@ -82,6 +104,28 @@ describe('useCalendarLinks', () => {
82104 expect ( outlookUrl . value ) . toContain ( 'location=Amsterdam' )
83105 } )
84106
107+ it ( 'includes url in body when no description' , ( ) => {
108+ const { outlookUrl } = useCalendarLinks ( {
109+ title : ref ( 'Test Event' ) ,
110+ startTs : ref ( START_TS ) ,
111+ endTs : ref ( null ) ,
112+ url : ref ( 'https://example.com' ) ,
113+ } )
114+ expect ( outlookUrl . value ) . toContain ( 'example.com' )
115+ } )
116+
117+ it ( 'prepends url before description in body' , ( ) => {
118+ const { outlookUrl } = useCalendarLinks ( {
119+ title : ref ( 'Test Event' ) ,
120+ startTs : ref ( START_TS ) ,
121+ endTs : ref ( null ) ,
122+ description : ref ( 'A description' ) ,
123+ url : ref ( 'https://example.com' ) ,
124+ } )
125+ const body = new URL ( outlookUrl . value ) . searchParams . get ( 'body' ) !
126+ expect ( body . indexOf ( 'example.com' ) ) . toBeLessThan ( body . indexOf ( 'A description' ) )
127+ } )
128+
85129 it ( 'points to outlook.live.com' , ( ) => {
86130 const { outlookUrl } = useCalendarLinks ( {
87131 title : ref ( 'Test Event' ) ,
@@ -114,6 +158,30 @@ describe('useCalendarLinks', () => {
114158 } )
115159 } )
116160
161+ describe ( 'Yahoo Calendar URL' , ( ) => {
162+ it ( 'includes url in desc when no description' , ( ) => {
163+ const { yahooUrl } = useCalendarLinks ( {
164+ title : ref ( 'Test Event' ) ,
165+ startTs : ref ( START_TS ) ,
166+ endTs : ref ( null ) ,
167+ url : ref ( 'https://example.com' ) ,
168+ } )
169+ expect ( yahooUrl . value ) . toContain ( 'example.com' )
170+ } )
171+
172+ it ( 'prepends url before description in desc' , ( ) => {
173+ const { yahooUrl } = useCalendarLinks ( {
174+ title : ref ( 'Test Event' ) ,
175+ startTs : ref ( START_TS ) ,
176+ endTs : ref ( null ) ,
177+ description : ref ( 'A description' ) ,
178+ url : ref ( 'https://example.com' ) ,
179+ } )
180+ const desc = new URL ( yahooUrl . value ) . searchParams . get ( 'desc' ) !
181+ expect ( desc . indexOf ( 'example.com' ) ) . toBeLessThan ( desc . indexOf ( 'A description' ) )
182+ } )
183+ } )
184+
117185 describe ( 'ICS content' , ( ) => {
118186 it ( 'contains VCALENDAR wrapper' , ( ) => {
119187 const { icsContent } = useCalendarLinks ( {
@@ -152,6 +220,30 @@ describe('useCalendarLinks', () => {
152220 expect ( icsContent . value ) . toContain ( 'SUMMARY:My Event' )
153221 } )
154222
223+ it ( 'includes URL property when url is provided' , ( ) => {
224+ const { icsContent } = useCalendarLinks ( {
225+ title : ref ( 'Test Event' ) ,
226+ startTs : ref ( START_TS ) ,
227+ endTs : ref ( null ) ,
228+ url : ref ( 'https://example.com' ) ,
229+ } )
230+ expect ( icsContent . value ) . toContain ( 'URL:https://example.com' )
231+ } )
232+
233+ it ( 'does not duplicate url in DESCRIPTION when both are provided' , ( ) => {
234+ const { icsContent } = useCalendarLinks ( {
235+ title : ref ( 'Test Event' ) ,
236+ startTs : ref ( START_TS ) ,
237+ endTs : ref ( null ) ,
238+ description : ref ( 'A description' ) ,
239+ url : ref ( 'https://example.com' ) ,
240+ } )
241+ expect ( icsContent . value ) . toContain ( 'URL:https://example.com' )
242+ expect ( icsContent . value ) . toContain ( 'DESCRIPTION:A description' )
243+ // url should appear exactly once (in URL: property, not also in DESCRIPTION)
244+ expect ( icsContent . value . split ( 'example.com' ) . length - 1 ) . toBe ( 1 )
245+ } )
246+
155247 it ( 'works across midnight (next-day end time)' , ( ) => {
156248 const { icsContent } = useCalendarLinks ( {
157249 title : ref ( 'Late Event' ) ,
0 commit comments