@@ -161,12 +161,17 @@ describe(`${FILE}`, () => {
161161 } )
162162 test ( 'should create a link in an existing floating window' , ( ) => {
163163 const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'filename' , '' , 'useExistingSubWindow' )
164- expect ( res ) . toEqual ( 'noteplan://x-callback-url/openNote?filename=foo&useExistingSubWindow=yes' )
164+ expect ( res ) . toEqual ( 'noteplan://x-callback-url/openNote?filename=foo&useExistingSubWindow=yes&subWindow=yes ' )
165165 } )
166166 test ( 'should create a link in split view' , ( ) => {
167167 const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'filename' , null , 'splitView' )
168168 expect ( res ) . toEqual ( 'noteplan://x-callback-url/openNote?filename=foo&splitView=yes' )
169169 } )
170+ test ( 'should create a link in reuse split view (reuseSplitView + splitView=yes)' , ( ) => {
171+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'filename' , '' , 'reuseSplitView' )
172+ expect ( res ) . toContain ( 'reuseSplitView=yes' )
173+ expect ( res ) . toContain ( 'splitView=yes' )
174+ } )
170175 test ( 'should ignore illegal openType' , ( ) => {
171176 const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'filename' , '' , 'baz' )
172177 expect ( res ) . toEqual ( 'noteplan://x-callback-url/openNote?filename=foo' )
@@ -183,6 +188,31 @@ describe(`${FILE}`, () => {
183188 expect ( res ) . toEqual ( 'noteplan://x-callback-url/openNote?filename=foo&blockID=%5E123456' )
184189 } )
185190 } )
191+ describe ( 'using timeframe (calendar notes)' , ( ) => {
192+ test ( 'should add timeframe=week for date note' , ( ) => {
193+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'today' , 'date' , '' , null , false , '' , 'week' )
194+ expect ( res ) . toContain ( 'noteDate=today' )
195+ expect ( res ) . toContain ( '&timeframe=week' )
196+ } )
197+ test ( 'should add timeframe=month for date note' , ( ) => {
198+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'today' , 'date' , '' , null , false , '' , 'month' )
199+ expect ( res ) . toContain ( '&timeframe=month' )
200+ } )
201+ test ( 'should not add timeframe for non-date paramType' , ( ) => {
202+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'filename' , '' , null , false , '' , 'week' )
203+ expect ( res ) . not . toContain ( 'timeframe=' )
204+ } )
205+ } )
206+ describe ( 'using highlightStart/highlightLength' , ( ) => {
207+ test ( 'should add highlightStart and highlightLength' , ( ) => {
208+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'title' , '' , null , false , '' , null , 0 , 9999 )
209+ expect ( res ) . toContain ( '&highlightStart=0&highlightLength=9999' )
210+ } )
211+ test ( 'should not add highlight for deleteNote' , ( ) => {
212+ const res = g . createOpenOrDeleteNoteCallbackUrl ( 'foo' , 'title' , '' , null , true , '' , null , 0 , 10 )
213+ expect ( res ) . not . toContain ( 'highlightStart' )
214+ } )
215+ } )
186216 } )
187217
188218 describe ( section ( `createRunPluginCallbackUrl` ) , ( ) => {
@@ -214,6 +244,28 @@ describe(`${FILE}`, () => {
214244 const exp = 'noteplan://x-callback-url/addText?noteDate=today&mode=prepend&openNote=yes&text=bar'
215245 expect ( g . createAddTextCallbackUrl ( 'today' , opts ) ) . toEqual ( exp )
216246 } )
247+ test ( 'should add subWindow=yes when openType is subWindow' , ( ) => {
248+ const opts = { text : 'bar' , mode : 'append' , openNote : 'yes' , openType : 'subWindow' }
249+ const res = g . createAddTextCallbackUrl ( 'today' , opts )
250+ expect ( res ) . toContain ( '&subWindow=yes' )
251+ } )
252+ test ( 'should add splitView=yes when openType is splitView' , ( ) => {
253+ const opts = { text : 'bar' , mode : 'append' , openNote : 'yes' , openType : 'splitView' }
254+ const res = g . createAddTextCallbackUrl ( 'today' , opts )
255+ expect ( res ) . toContain ( '&splitView=yes' )
256+ } )
257+ test ( 'should add reuseSplitView=yes and splitView=yes when openType is reuseSplitView' , ( ) => {
258+ const opts = { text : 'bar' , mode : 'append' , openNote : 'yes' , openType : 'reuseSplitView' }
259+ const res = g . createAddTextCallbackUrl ( 'today' , opts )
260+ expect ( res ) . toContain ( '&reuseSplitView=yes' )
261+ expect ( res ) . toContain ( '&splitView=yes' )
262+ } )
263+ test ( 'should add useExistingSubWindow=yes and subWindow=yes when openType is useExistingSubWindow' , ( ) => {
264+ const opts = { text : 'bar' , mode : 'append' , openNote : 'yes' , openType : 'useExistingSubWindow' }
265+ const res = g . createAddTextCallbackUrl ( 'today' , opts )
266+ expect ( res ) . toContain ( '&useExistingSubWindow=yes' )
267+ expect ( res ) . toContain ( '&subWindow=yes' )
268+ } )
217269 } )
218270
219271 describe ( section ( 'createPrettyOpenNoteLink()' ) , ( ) => {
@@ -327,6 +379,21 @@ describe(`${FILE}`, () => {
327379 `${ base } text?arg0=%7B%22excludeToday%22%3Afalse%2C%22progressHeading%22%3A%22Test%20Heading%22%2C%22progressYesNo%22%3A%22%23readbook%2C%23theology%22%7D` ,
328380 )
329381 } )
382+ test ( 'should create selectTag callback with name param' , ( ) => {
383+ const result = g . createCallbackUrl ( 'selectTag' , { name : '#noteplan' } )
384+ expect ( result ) . toEqual ( `${ base } selectTag?name=%23noteplan` )
385+ } )
386+ test ( 'should create installPlugin callback with pluginID param' , ( ) => {
387+ const result = g . createCallbackUrl ( 'installPlugin' , { pluginID : 'dwertheimer.Favorites' } )
388+ expect ( result ) . toEqual ( `${ base } installPlugin?pluginID=dwertheimer.Favorites` )
389+ } )
390+ test ( 'should create toggleSidebar callback with forceCollapse and forceOpen' , ( ) => {
391+ const result = g . createCallbackUrl ( 'toggleSidebar' , { forceCollapse : 'yes' , forceOpen : 'no' , animated : 'no' } )
392+ expect ( result ) . toContain ( 'toggleSidebar' )
393+ expect ( result ) . toContain ( 'forceCollapse=yes' )
394+ expect ( result ) . toContain ( 'forceOpen=no' )
395+ expect ( result ) . toContain ( 'animated=no' )
396+ } )
330397 } )
331398 /*
332399 * forceLeadingSlash()
0 commit comments