@@ -75,3 +75,52 @@ describe('TaskLocation', () => {
7575 expect ( TaskLocation . fromUnknownPosition ( new TasksFile ( '' ) ) . hasKnownPath ) . toBe ( false ) ;
7676 } ) ;
7777} ) ;
78+
79+ describe ( 'TaskLocation - identicalTo' , function ( ) {
80+ const tasksFile : TasksFile = new TasksFile ( 'x.md' ) ;
81+ const lineNumber : number = 40 ;
82+ const sectionStart : number = 30 ;
83+ const sectionIndex : number = 3 ;
84+ const precedingHeader : string | null = 'heading' ;
85+
86+ const lhs = new TaskLocation ( tasksFile , lineNumber , sectionStart , sectionIndex , precedingHeader ) ;
87+
88+ it ( 'should detect identical objects' , ( ) => {
89+ const rhs = new TaskLocation ( tasksFile , lineNumber , sectionStart , sectionIndex , precedingHeader ) ;
90+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( true ) ;
91+ } ) ;
92+
93+ it ( 'should check tasksFile' , ( ) => {
94+ const rhs = new TaskLocation ( new TasksFile ( 'y.md' ) , lineNumber , sectionStart , sectionIndex , precedingHeader ) ;
95+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
96+ } ) ;
97+
98+ it ( 'should check lineNumber' , ( ) => {
99+ const rhs = new TaskLocation ( tasksFile , 0 , sectionStart , sectionIndex , precedingHeader ) ;
100+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
101+ } ) ;
102+
103+ it ( 'should check sectionStart' , ( ) => {
104+ const rhs = new TaskLocation ( tasksFile , lineNumber , 0 , sectionIndex , precedingHeader ) ;
105+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
106+ } ) ;
107+
108+ it ( 'should check sectionIndex' , ( ) => {
109+ const rhs = new TaskLocation ( tasksFile , lineNumber , sectionStart , 0 , precedingHeader ) ;
110+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
111+ } ) ;
112+
113+ it ( 'should check precedingHeader' , ( ) => {
114+ {
115+ const precedingHeader = null ;
116+ const rhs = new TaskLocation ( tasksFile , lineNumber , sectionStart , sectionIndex , precedingHeader ) ;
117+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
118+ }
119+
120+ {
121+ const precedingHeader = 'different header' ;
122+ const rhs = new TaskLocation ( tasksFile , lineNumber , sectionStart , sectionIndex , precedingHeader ) ;
123+ expect ( lhs . identicalTo ( rhs ) ) . toEqual ( false ) ;
124+ }
125+ } ) ;
126+ } ) ;
0 commit comments