@@ -236,22 +236,30 @@ describe("USJ Marker Action Utils", () => {
236236 } ) ;
237237
238238 describe ( "should insert a note" , ( ) => {
239+ const referenceCVText = `${ reference . chapterNum } :${ reference . verseNum } ` ;
240+
239241 it ( "of type footnote" , ( ) => {
240242 const { editor } = createBasicTestEnvironment ( nodes , $defaultInitialEditorState ) ;
241243 const markerAction = getUsjMarkerAction ( "f" , expandedNoteKeyRef , undefined , undefined , {
242244 discrete : true ,
243245 } ) ;
246+ // caret after the word "second"
244247 updateSelection ( editor , secondVerseTextNode , 6 ) ;
245248
246249 markerAction . action ( { editor, reference } ) ;
247250
248251 editor . getEditorState ( ) . read ( ( ) => {
249252 expect ( secondVerseTextNode . getTextContent ( ) ) . toBe ( "second" ) ;
250253 const insertedNode = secondVerseTextNode . getNextSibling ( ) ;
251- if ( ! $isNoteNode ( insertedNode ) ) throw new Error ( "Inserted node is not a note " ) ;
254+ if ( ! $isNoteNode ( insertedNode ) ) throw new Error ( "Expected a NoteNode " ) ;
252255 expect ( insertedNode . getMarker ( ) ) . toBe ( "f" ) ;
256+
257+ const frChar = insertedNode . getChildAtIndex ( 2 ) ;
258+ if ( ! $isCharNode ( frChar ) ) throw new Error ( "Expected a CharNode" ) ;
259+ expect ( frChar . getTextContent ( ) ) . toBe ( referenceCVText ) ;
260+
253261 const tailTextNode = insertedNode . getNextSibling ( ) ;
254- if ( ! $isTextNode ( tailTextNode ) ) throw new Error ( "Tail node is not text " ) ;
262+ if ( ! $isTextNode ( tailTextNode ) ) throw new Error ( "Expected a TextNode " ) ;
255263 expect ( tailTextNode . getTextContent ( ) ) . toBe ( " verse text " ) ;
256264 } ) ;
257265 } ) ;
@@ -261,6 +269,7 @@ describe("USJ Marker Action Utils", () => {
261269 const markerAction = getUsjMarkerAction ( "fe" , expandedNoteKeyRef , undefined , undefined , {
262270 discrete : true ,
263271 } ) ;
272+ // caret after the word "second"
264273 updateSelection ( editor , secondVerseTextNode , 6 ) ;
265274
266275 markerAction . action ( { editor, reference } ) ;
@@ -281,6 +290,7 @@ describe("USJ Marker Action Utils", () => {
281290 const markerAction = getUsjMarkerAction ( "ef" , expandedNoteKeyRef , undefined , undefined , {
282291 discrete : true ,
283292 } ) ;
293+ // caret after the word "second"
284294 updateSelection ( editor , secondVerseTextNode , 6 ) ;
285295
286296 markerAction . action ( { editor, reference } ) ;
@@ -301,17 +311,23 @@ describe("USJ Marker Action Utils", () => {
301311 const markerAction = getUsjMarkerAction ( "x" , expandedNoteKeyRef , undefined , undefined , {
302312 discrete : true ,
303313 } ) ;
314+ // caret after the word "second"
304315 updateSelection ( editor , secondVerseTextNode , 6 ) ;
305316
306317 markerAction . action ( { editor, reference } ) ;
307318
308319 editor . getEditorState ( ) . read ( ( ) => {
309320 expect ( secondVerseTextNode . getTextContent ( ) ) . toBe ( "second" ) ;
310321 const insertedNode = secondVerseTextNode . getNextSibling ( ) ;
311- if ( ! $isNoteNode ( insertedNode ) ) throw new Error ( "Inserted node is not a note " ) ;
322+ if ( ! $isNoteNode ( insertedNode ) ) throw new Error ( "Expected a NoteNode " ) ;
312323 expect ( insertedNode . getMarker ( ) ) . toBe ( "x" ) ;
324+
325+ const xoChar = insertedNode . getChildAtIndex ( 2 ) ;
326+ if ( ! $isCharNode ( xoChar ) ) throw new Error ( "Expected a CharNode" ) ;
327+ expect ( xoChar . getTextContent ( ) ) . toBe ( referenceCVText ) ;
328+
313329 const tailTextNode = insertedNode . getNextSibling ( ) ;
314- if ( ! $isTextNode ( tailTextNode ) ) throw new Error ( "Tail node is not text " ) ;
330+ if ( ! $isTextNode ( tailTextNode ) ) throw new Error ( "Expected a TextNode " ) ;
315331 expect ( tailTextNode . getTextContent ( ) ) . toBe ( " verse text " ) ;
316332 } ) ;
317333 } ) ;
@@ -321,6 +337,7 @@ describe("USJ Marker Action Utils", () => {
321337 const markerAction = getUsjMarkerAction ( "ex" , expandedNoteKeyRef , undefined , undefined , {
322338 discrete : true ,
323339 } ) ;
340+ // caret after the word "second"
324341 updateSelection ( editor , secondVerseTextNode , 6 ) ;
325342
326343 markerAction . action ( { editor, reference } ) ;
0 commit comments