@@ -105,14 +105,14 @@ describe("Sidebar Styling", () => {
105105 expect ( sidebar . style . transition ) . toContain ( "left 0.3s ease" ) ;
106106 } ) ;
107107
108-
108+
109109} ) ;
110110
111111// testing for viewer display
112112
113113describe ( "Viewer Display Logic" , ( ) => {
114114 let mockBoneData ;
115-
115+
116116 beforeEach ( ( ) => {
117117 // Add viewer HTML elements to the DOM
118118 const viewerHTML = `
@@ -124,7 +124,7 @@ describe("Viewer Display Logic", () => {
124124 </div>
125125 ` ;
126126 document . body . innerHTML += viewerHTML ;
127-
127+
128128 // Mock the bone data structure
129129 mockBoneData = {
130130 bones : [
@@ -149,7 +149,7 @@ describe("Viewer Display Logic", () => {
149149 }
150150 ]
151151 } ;
152-
152+
153153 // Mock fetch for the mock data file
154154 global . fetch = jest . fn ( ( url ) => {
155155 if ( url . includes ( "mock-bone-data.json" ) ) {
@@ -174,12 +174,12 @@ describe("Viewer Display Logic", () => {
174174 test ( "bone image src attribute is correctly updated after selection" , ( ) => {
175175 const boneImage = document . getElementById ( "bone-image" ) ;
176176 const bone = mockBoneData . bones [ 0 ] ;
177-
177+
178178 // Simulate the displayBoneData function logic
179179 boneImage . src = bone . image_url ;
180180 boneImage . alt = `${ bone . name } bone image` ;
181181 boneImage . style . display = "block" ;
182-
182+
183183 expect ( boneImage . src ) . toBe ( "https://via.placeholder.com/600x400/4A90E2/FFFFFF?text=Ischium+Bone" ) ;
184184 expect ( boneImage . alt ) . toBe ( "Ischium bone image" ) ;
185185 expect ( boneImage . style . display ) . toBe ( "block" ) ;
@@ -188,27 +188,27 @@ describe("Viewer Display Logic", () => {
188188 test ( "correct number of annotation elements are created in annotations overlay" , ( ) => {
189189 const annotationsOverlay = document . getElementById ( "annotations-overlay" ) ;
190190 const bone = mockBoneData . bones [ 0 ] ;
191-
191+
192192 // Clear previous content
193193 annotationsOverlay . innerHTML = "" ;
194-
194+
195195 // Simulate the displayAnnotations function logic
196196 const annotationsList = document . createElement ( "ul" ) ;
197197 annotationsList . className = "annotations-list" ;
198-
198+
199199 bone . annotations . forEach ( ( annotation ) => {
200200 const listItem = document . createElement ( "li" ) ;
201201 listItem . className = "annotation-item" ;
202202 listItem . textContent = annotation . text ;
203203 annotationsList . appendChild ( listItem ) ;
204204 } ) ;
205-
205+
206206 annotationsOverlay . appendChild ( annotationsList ) ;
207-
207+
208208 // Verify correct number of annotations
209209 const annotationItems = annotationsOverlay . querySelectorAll ( ".annotation-item" ) ;
210210 expect ( annotationItems ) . toHaveLength ( 3 ) ;
211-
211+
212212 // Verify annotation content
213213 expect ( annotationItems [ 0 ] . textContent ) . toBe ( "Ischial Tuberosity - Attachment point for hamstring muscles" ) ;
214214 expect ( annotationItems [ 1 ] . textContent ) . toBe ( "Ischial Spine - Forms part of the lesser sciatic notch" ) ;
@@ -218,67 +218,69 @@ describe("Viewer Display Logic", () => {
218218 test ( "placeholder message is shown when no bone is selected" , ( ) => {
219219 const boneImage = document . getElementById ( "bone-image" ) ;
220220 const annotationsOverlay = document . getElementById ( "annotations-overlay" ) ;
221-
221+
222222 // Simulate clearBoneDisplay function logic
223223 boneImage . src = "" ;
224224 boneImage . alt = "" ;
225225 boneImage . style . display = "none" ;
226226 annotationsOverlay . innerHTML = "<p>Select a bone to view image and annotations.</p>" ;
227-
227+
228228 expect ( boneImage . src ) . toBe ( "" ) ;
229229 expect ( boneImage . style . display ) . toBe ( "none" ) ;
230230 expect ( annotationsOverlay . innerHTML ) . toBe ( "<p>Select a bone to view image and annotations.</p>" ) ;
231231 } ) ;
232232
233233 test ( "handles bone with no annotations gracefully" , ( ) => {
234234 const annotationsOverlay = document . getElementById ( "annotations-overlay" ) ;
235-
235+
236236 // Simulate bone with empty annotations array
237237 const boneWithNoAnnotations = {
238238 id : "test_bone" ,
239239 name : "Test Bone" ,
240240 image_url : "test-url.jpg" ,
241241 annotations : [ ]
242242 } ;
243-
243+
244244 // Clear previous content
245245 annotationsOverlay . innerHTML = "" ;
246-
246+
247247 // Simulate displayAnnotations with empty array
248248 if ( ! boneWithNoAnnotations . annotations || boneWithNoAnnotations . annotations . length === 0 ) {
249249 annotationsOverlay . innerHTML = "<p>No annotations available for this bone.</p>" ;
250250 }
251-
251+
252252 expect ( annotationsOverlay . innerHTML ) . toBe ( "<p>No annotations available for this bone.</p>" ) ;
253253 } ) ;
254254
255255 test ( "annotation items have correct CSS classes" , ( ) => {
256256 const annotationsOverlay = document . getElementById ( "annotations-overlay" ) ;
257257 const bone = mockBoneData . bones [ 0 ] ;
258-
258+
259259 // Clear and populate annotations
260260 annotationsOverlay . innerHTML = "" ;
261261 const annotationsList = document . createElement ( "ul" ) ;
262262 annotationsList . className = "annotations-list" ;
263-
263+
264264 bone . annotations . forEach ( ( annotation ) => {
265265 const listItem = document . createElement ( "li" ) ;
266266 listItem . className = "annotation-item" ;
267267 listItem . textContent = annotation . text ;
268268 annotationsList . appendChild ( listItem ) ;
269269 } ) ;
270-
270+
271271 annotationsOverlay . appendChild ( annotationsList ) ;
272-
272+
273273 // Verify CSS classes
274274 const list = annotationsOverlay . querySelector ( "ul" ) ;
275275 expect ( list . className ) . toBe ( "annotations-list" ) ;
276-
276+
277277 const items = annotationsOverlay . querySelectorAll ( "li" ) ;
278278 items . forEach ( item => {
279279 expect ( item . className ) . toBe ( "annotation-item" ) ;
280280 } ) ;
281- = === ===
281+
282+ } ) ;
283+
282284} ) ;
283285
284286describe ( "Help Modal Functionality" , ( ) => {
@@ -304,35 +306,35 @@ describe("Help Modal Functionality", () => {
304306 test ( "modal becomes visible when Help button is clicked" , ( ) => {
305307 const helpButton = document . getElementById ( "text-button-Help" ) ;
306308 const helpModal = document . getElementById ( "help-modal" ) ;
307-
309+
308310 helpButton . click ( ) ;
309-
311+
310312 expect ( helpModal . classList . contains ( "is-visible" ) ) . toBeTruthy ( ) ;
311313 } ) ;
312314
313315 test ( "modal becomes hidden when Close button is clicked" , ( ) => {
314316 const helpModal = document . getElementById ( "help-modal" ) ;
315317 const closeButton = document . getElementById ( "close-help-modal" ) ;
316-
318+
317319 // First make modal visible
318320 helpModal . classList . add ( "is-visible" ) ;
319-
321+
320322 // Then click close button
321323 closeButton . click ( ) ;
322-
324+
323325 expect ( helpModal . classList . contains ( "is-visible" ) ) . toBeFalsy ( ) ;
324326 } ) ;
325327
326328 test ( "modal closes when Escape key is pressed" , ( ) => {
327329 const helpModal = document . getElementById ( "help-modal" ) ;
328-
330+
329331 // First make modal visible
330332 helpModal . classList . add ( "is-visible" ) ;
331-
333+
332334 // Simulate pressing Escape key
333335 const escapeKeyEvent = new KeyboardEvent ( "keydown" , { key : "Escape" } ) ;
334336 document . dispatchEvent ( escapeKeyEvent ) ;
335-
337+
336338 expect ( helpModal . classList . contains ( "is-visible" ) ) . toBeFalsy ( ) ;
337339
338340 } ) ;
0 commit comments