@@ -3,23 +3,29 @@ import { mockDatabaseItem } from "../../../utils/mocking.helpers";
33import { tryResolveLocation } from "../../../../../src/databases/local-databases/locations" ;
44
55describe ( "tryResolveLocation" , ( ) => {
6+ const resolveSourceFile = jest . fn ( ) ;
7+
8+ const databaseItem = mockDatabaseItem ( {
9+ resolveSourceFile,
10+ } ) ;
11+
12+ beforeEach ( ( ) => {
13+ resolveSourceFile . mockReturnValue ( Uri . file ( "abc" ) ) ;
14+ } ) ;
15+
616 it ( "should resolve a whole file location" , ( ) => {
7- const databaseItem = mockDatabaseItem ( ) ;
817 expect ( tryResolveLocation ( "file://hucairz:0:0:0:0" , databaseItem ) ) . toEqual (
918 new Location ( Uri . file ( "abc" ) , new Range ( 0 , 0 , 0 , 0 ) ) ,
1019 ) ;
1120 } ) ;
1221
1322 it ( "should resolve a five-part location edge case" , ( ) => {
14- const databaseItem = mockDatabaseItem ( ) ;
1523 expect ( tryResolveLocation ( "file://hucairz:1:1:1:1" , databaseItem ) ) . toEqual (
1624 new Location ( Uri . file ( "abc" ) , new Range ( 0 , 0 , 0 , 1 ) ) ,
1725 ) ;
1826 } ) ;
1927
2028 it ( "should resolve a five-part location" , ( ) => {
21- const databaseItem = mockDatabaseItem ( ) ;
22-
2329 expect (
2430 tryResolveLocation (
2531 {
@@ -33,7 +39,7 @@ describe("tryResolveLocation", () => {
3339 ) ,
3440 ) . toEqual (
3541 new Location (
36- Uri . parse ( "abc" ) ,
42+ Uri . file ( "abc" ) ,
3743 new Range ( new Position ( 4 , 3 ) , new Position ( 3 , 0 ) ) ,
3844 ) ,
3945 ) ;
@@ -42,8 +48,6 @@ describe("tryResolveLocation", () => {
4248 } ) ;
4349
4450 it ( "should resolve a five-part location with an empty path" , ( ) => {
45- const databaseItem = mockDatabaseItem ( ) ;
46-
4751 expect (
4852 tryResolveLocation (
4953 {
@@ -59,21 +63,17 @@ describe("tryResolveLocation", () => {
5963 } ) ;
6064
6165 it ( "should resolve a string location for whole file" , ( ) => {
62- const databaseItem = mockDatabaseItem ( ) ;
63-
6466 expect ( tryResolveLocation ( "file://hucairz:0:0:0:0" , databaseItem ) ) . toEqual (
65- new Location ( Uri . parse ( "abc" ) , new Range ( 0 , 0 , 0 , 0 ) ) ,
67+ new Location ( Uri . file ( "abc" ) , new Range ( 0 , 0 , 0 , 0 ) ) ,
6668 ) ;
6769 expect ( databaseItem . resolveSourceFile ) . toHaveBeenCalledTimes ( 1 ) ;
6870 expect ( databaseItem . resolveSourceFile ) . toHaveBeenCalledWith ( "hucairz" ) ;
6971 } ) ;
7072
7173 it ( "should resolve a string location for five-part location" , ( ) => {
72- const databaseItem = mockDatabaseItem ( ) ;
73-
7474 expect ( tryResolveLocation ( "file://hucairz:5:4:3:2" , databaseItem ) ) . toEqual (
7575 new Location (
76- Uri . parse ( "abc" ) ,
76+ Uri . file ( "abc" ) ,
7777 new Range ( new Position ( 4 , 3 ) , new Position ( 2 , 2 ) ) ,
7878 ) ,
7979 ) ;
@@ -82,8 +82,6 @@ describe("tryResolveLocation", () => {
8282 } ) ;
8383
8484 it ( "should resolve a string location for invalid string" , ( ) => {
85- const databaseItem = mockDatabaseItem ( ) ;
86-
8785 expect (
8886 tryResolveLocation ( "file://hucairz:x:y:z:a" , databaseItem ) ,
8987 ) . toBeUndefined ( ) ;
0 commit comments