1- import type { Reference } from 'obsidian' ;
21import { TasksFile } from '../../src/Scripting/TasksFile' ;
32import { Link } from '../../src/Task/Link' ;
43import internal_heading_links from '../Obsidian/__test_data__/internal_heading_links.json' ;
@@ -7,7 +6,6 @@ import link_in_task_markdown_link from '../Obsidian/__test_data__/link_in_task_m
76import link_in_task_wikilink from '../Obsidian/__test_data__/link_in_task_wikilink.json' ;
87import link_is_broken from '../Obsidian/__test_data__/link_is_broken.json' ;
98
10- import link_in_file_body from '../Obsidian/__test_data__/link_in_file_body.json' ;
119import links_everywhere from '../Obsidian/__test_data__/links_everywhere.json' ;
1210import { allCacheSampleData } from '../Obsidian/AllCacheSampleData' ;
1311import type { SimulatedFile } from '../Obsidian/SimulatedFile' ;
@@ -20,7 +18,11 @@ import { getFirstLinkpathDest, getFirstLinkpathDestFromData } from '../__mocks__
2018function getLink ( data : any , index : number ) {
2119 const rawLink = data . cachedMetadata . links [ index ] ;
2220 const destinationPath = getFirstLinkpathDestFromData ( data , rawLink ) ;
23- return new Link ( rawLink , data . filePath , destinationPath ) ;
21+
22+ const resolver = LinkResolver . getInstance ( ) ;
23+ resolver . setGetFirstLinkpathDestFn ( ( ) => destinationPath ) ;
24+
25+ return new Link ( rawLink , data . filePath ) ;
2426}
2527
2628describe ( 'linkClass' , ( ) => {
@@ -261,31 +263,6 @@ describe('linkClass', () => {
261263 // []() and [alias]() are not detected by the obsidian parser as a link
262264 } ) ;
263265
264- describe ( 'destinationPath tests' , ( ) => {
265- it ( 'should accept and return destinationPath' , ( ) => {
266- const data = link_in_file_body ;
267- const rawLink = data . cachedMetadata . links [ 0 ] ;
268- expect ( rawLink . original ) . toEqual ( '[[yaml_tags_is_empty]]' ) ;
269- expect ( rawLink . link ) . toEqual ( 'yaml_tags_is_empty' ) ;
270-
271- const destinationPath = 'Test Data/yaml_tags_is_empty.md' ;
272- const link = new Link ( rawLink , data . filePath , destinationPath ) ;
273-
274- expect ( link . destinationPath ) . toEqual ( destinationPath ) ;
275- } ) ;
276-
277- it ( 'should return null path if destinationPath not supplied' , ( ) => {
278- const data = link_in_file_body ;
279- const rawLink = data . cachedMetadata . links [ 0 ] ;
280- expect ( rawLink . original ) . toEqual ( '[[yaml_tags_is_empty]]' ) ;
281- expect ( rawLink . link ) . toEqual ( 'yaml_tags_is_empty' ) ;
282-
283- const link = new Link ( rawLink , data . filePath ) ;
284-
285- expect ( link . destinationPath ) . toBeNull ( ) ;
286- } ) ;
287- } ) ;
288-
289266 describe ( 'linksTo() tests' , ( ) => {
290267 it ( 'matches filenames' , ( ) => {
291268 const link = getLink ( links_everywhere , 0 ) ;
@@ -329,9 +306,7 @@ describe('linkClass', () => {
329306
330307describe ( 'visualise links' , ( ) => {
331308 beforeAll ( ( ) => {
332- LinkResolver . getInstance ( ) . setGetFirstLinkpathDestFn ( ( rawLink : Reference , sourcePath : string ) => {
333- return getFirstLinkpathDest ( rawLink , sourcePath ) ;
334- } ) ;
309+ LinkResolver . getInstance ( ) . setGetFirstLinkpathDestFn ( getFirstLinkpathDest ) ;
335310 } ) ;
336311
337312 afterAll ( ( ) => {
0 commit comments