Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cd19093
fix: 🐛 updateSegmentationStats segmentation clone strategy
ViniciusResende Sep 26, 2025
9709652
test: 💍 added unit tests for the updateSegmentationStats util
ViniciusResende Sep 26, 2025
a41ac45
test: 💍 added unit tests for segmentUtils file
ViniciusResende Sep 26, 2025
5566da7
fix: 🐛 typescript errors at toggleVOISliceSync file
ViniciusResende Sep 26, 2025
0f1855e
test: 💍 added unit test for toggleVOISliceSync at cs extension
ViniciusResende Sep 26, 2025
1d8de06
test: 💍 add unit test for setUpSegmentationEventHandlers
ViniciusResende Sep 26, 2025
bddda95
fix: 🐛 removing unreachable code from setupSegmentationModified
ViniciusResende Sep 26, 2025
07f470f
test: 💍 added unit tests for segmentationHandlers utility
ViniciusResende Sep 26, 2025
b697aea
test: 💍 added unit tests for removeViewportSegmentationRepresen
ViniciusResende Sep 26, 2025
4d07800
fix: 🐛 getDialogId was handling an unexistent HydrationType
ViniciusResende Sep 26, 2025
a619b16
test: 💍 added unit tests for promptHydrationDialog
ViniciusResende Sep 26, 2025
e79c1ae
test: 💍 added unit tests for nthLoader util
ViniciusResende Sep 29, 2025
c2e415e
test: 💍 added unit tests for getCenterExtent util
ViniciusResende Sep 29, 2025
3f598df
test: 💍 added unit tests for isMeasurementWithinViewport util
ViniciusResende Sep 29, 2025
c0c1723
test: 💍 add unit test for isReferenceViewable cornerstone util
ViniciusResende Sep 29, 2025
7a420c1
fix: 🐛 removed unused logic at interleaveTopToBottom
ViniciusResende Sep 30, 2025
fc5efc6
test: 💍 added unit tests for interleaveTopToBottom function
ViniciusResende Sep 30, 2025
fcaa079
chore: 🤖 moved interleave js file to ts
ViniciusResende Sep 30, 2025
2d44cfb
test: 💍 added unit tests for interleaveCenterLoader
ViniciusResende Sep 30, 2025
ec04bc5
fix: 🐛 interleave algorithm iterator skipping issue
ViniciusResende Sep 30, 2025
bf05cb1
test: 💍 added unit tests for the interleave algorithm
ViniciusResende Sep 30, 2025
4fb380c
test: 💍 added unit tests for initWebWorkerProgressHandler
ViniciusResende Sep 30, 2025
2bcd340
test: 💍 added unit tests for initViewTiming
ViniciusResende Sep 30, 2025
4d2c2f8
test: 💍 added hydrationUtils unit tests at cornerstone ext
ViniciusResende Oct 1, 2025
2debcb4
test: 💍 add unit test for getViewportOrientationFromImageOrient
ViniciusResende Oct 1, 2025
353c844
test: 💍 added unit tests for getViewportEnabledElement.test
ViniciusResende Oct 1, 2025
c81e2d5
feat: 🎸 converting getNthFrames utility to typescript
ViniciusResende Oct 1, 2025
7d89dae
test: 💍 added unit tests for getNthFrames util function
ViniciusResende Oct 1, 2025
e5ae00e
fix: 🐛 added typing and edge case handling for getInterleavedFr
ViniciusResende Oct 1, 2025
25874b3
test: 💍 added unit tests for getInterleavedFrames
ViniciusResende Oct 1, 2025
58ad4ff
test: 💍 added unit tests for getCornerstoneViewportType
ViniciusResende Oct 1, 2025
12891c5
test: 💍 added unit tests for getCornerstoneOrientation
ViniciusResende Oct 2, 2025
4fa6af1
test: 💍 added unit tests for getCornerstoneBlendMode utility
ViniciusResende Oct 2, 2025
03ed3fe
test: 💍 added unit tests for getActiveViewportEnabledElement
ViniciusResende Oct 2, 2025
3ab6e2a
test: 💍 added unit tests for findNearbyToolData util
ViniciusResende Oct 2, 2025
8fb8eb9
test: 💍 added unit tests for generateSegmentationCSVReport util
ViniciusResende Oct 2, 2025
f12b20b
test: 💍 fix consistency on result assrtion
ViniciusResende Oct 7, 2025
feda2fc
test: 💍 remove unecessary result variable that wasn't asserted
ViniciusResende Oct 7, 2025
67912ab
Merge branch 'master' of https://github.com/OHIF/Viewers into test/co…
ViniciusResende Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions extensions/cornerstone/src/utils/findNearbyToolData.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { findNearbyToolData } from './findNearbyToolData';

describe('findNearbyToolData', () => {
const mockCommandsManager = {
runCommand: jest.fn(),
};

beforeEach(() => {
jest.clearAllMocks();
});

it('should return undefined when event is null', () => {
const result = findNearbyToolData(mockCommandsManager, null);

expect(result).toBeUndefined();
expect(mockCommandsManager.runCommand).not.toHaveBeenCalled();
});

it('should return undefined when event is undefined', () => {
const result = findNearbyToolData(mockCommandsManager, undefined);

expect(result).toBeUndefined();
expect(mockCommandsManager.runCommand).not.toHaveBeenCalled();
});

it('should return undefined when event has no detail', () => {
const event = {};
const result = findNearbyToolData(mockCommandsManager, event);

expect(result).toBeUndefined();
expect(mockCommandsManager.runCommand).not.toHaveBeenCalled();
});

it('should return undefined when event detail is null', () => {
const event = { detail: null };
const result = findNearbyToolData(mockCommandsManager, event);

expect(result).toBeUndefined();
expect(mockCommandsManager.runCommand).not.toHaveBeenCalled();
});

it('should call runCommand with correct parameters when event has valid detail', () => {
const mockElement = document.createElement('div');
const mockCurrentPoints = { canvas: { x: 100, y: 200 } };
const mockToolData = { id: 'annotation-1' };
const event = {
detail: {
element: mockElement,
currentPoints: mockCurrentPoints,
},
};

mockCommandsManager.runCommand.mockReturnValue(mockToolData);

const result = findNearbyToolData(mockCommandsManager, event);

expect(mockCommandsManager.runCommand).toHaveBeenCalledWith(
'getNearbyAnnotation',
{
element: mockElement,
canvasCoordinates: mockCurrentPoints.canvas,
},
'CORNERSTONE'
);
expect(result).toBe(mockToolData);
});

it('should handle event with element but no currentPoints', () => {
const mockElement = document.createElement('div');
const event = {
detail: {
element: mockElement,
},
};

findNearbyToolData(mockCommandsManager, event);

expect(mockCommandsManager.runCommand).toHaveBeenCalledWith(
'getNearbyAnnotation',
{
element: mockElement,
canvasCoordinates: undefined,
},
'CORNERSTONE'
);
});

it('should handle event with currentPoints but no canvas coordinates', () => {
const mockElement = document.createElement('div');
const mockCurrentPoints = {};
const event = {
detail: {
element: mockElement,
currentPoints: mockCurrentPoints,
},
};

findNearbyToolData(mockCommandsManager, event);

expect(mockCommandsManager.runCommand).toHaveBeenCalledWith(
'getNearbyAnnotation',
{
element: mockElement,
canvasCoordinates: undefined,
},
'CORNERSTONE'
);
});

it('should return result from runCommand', () => {
const mockToolData = { id: 'test-annotation', data: 'test-data' };
const event = {
detail: {
element: document.createElement('div'),
currentPoints: { canvas: { x: 50, y: 75 } },
},
};

mockCommandsManager.runCommand.mockReturnValue(mockToolData);

const result = findNearbyToolData(mockCommandsManager, event);

expect(result).toBe(mockToolData);
});
});
Loading