import { describe, it, expect, beforeEach } from '@jest/globals'; import { ZoomSwitchControl, ZoomSwitchOrientation } from '../src'; import { loadMockDefaults } from '../__mocks__/Defaults'; beforeEach(() => { loadMockDefaults(); }); describe('ZoomSwitchControl', () => { describe('default constructor', () => { it('initializes with default v2 properties', () => { const control = new ZoomSwitchControl(); expect(control.orientation).toBe(ZoomSwitchOrientation.Horizontal); expect(control.isAlwaysExpanded).toBe(false); expect(control.isExpanded).toBe(false); expect(control.accessibilityLabel).toBe('Zoom '); expect(control.accessibilityHint).toBe('Adjusts the camera zoom level'); expect(control.selectedZoomLevel).toBe(1); }); it('initializes with null legacy accessibility properties', () => { const control = new ZoomSwitchControl(); expect(control.contentDescriptionWhenZoomedOut).toBeNull(); expect(control.contentDescriptionWhenZoomedIn).toBeNull(); expect(control.accessibilityLabelWhenZoomedOut).toBeNull(); expect(control.accessibilityLabelWhenZoomedIn).toBeNull(); expect(control.accessibilityHintWhenZoomedOut).toBeNull(); expect(control.accessibilityHintWhenZoomedIn).toBeNull(); }); }); describe('v2 property setters', () => { it('allows setting orientation to Vertical', () => { const control = new ZoomSwitchControl(); control.orientation = ZoomSwitchOrientation.Vertical; expect(control.orientation).toBe(ZoomSwitchOrientation.Vertical); }); it('allows setting isAlwaysExpanded', () => { const control = new ZoomSwitchControl(); control.isAlwaysExpanded = true; expect(control.isAlwaysExpanded).toBe(true); }); it('allows setting isExpanded', () => { const control = new ZoomSwitchControl(); control.isExpanded = true; expect(control.isExpanded).toBe(true); }); it('allows setting accessibilityLabel', () => { const control = new ZoomSwitchControl(); control.accessibilityLabel = 'Camera zoom'; expect(control.accessibilityLabel).toBe('Camera zoom'); }); it('allows setting accessibilityHint', () => { const control = new ZoomSwitchControl(); control.accessibilityHint = 'Double tap to zoom'; expect(control.accessibilityHint).toBe('Double tap to zoom'); }); }); describe('selectedZoomLevel', () => { it('is read-only (no public setter)', () => { const control = new ZoomSwitchControl(); expect(control.selectedZoomLevel).toBe(1); }); }); describe('JSON serialization', () => { it('serializes v2 properties with correct JSON keys', () => { const control = new ZoomSwitchControl(); control.orientation = ZoomSwitchOrientation.Vertical; control.isAlwaysExpanded = true; control.isExpanded = true; control.accessibilityLabel = 'Camera zoom'; control.accessibilityHint = 'Double tap'; const json = JSON.parse(JSON.stringify(control)); expect(json.type).toBe('zoom'); expect(json.orientation).toBe('vertical'); expect(json.isAlwaysExpanded).toBe(true); expect(json.isExpanded).toBe(true); expect(json.accessibilityLabel).toBe('Camera zoom'); expect(json.accessibilityHint).toBe('Double tap'); }); it('does not serialize selectedZoomLevel', () => { const control = new ZoomSwitchControl(); const json = JSON.parse(JSON.stringify(control)); expect(json.selectedZoomLevel).toBeUndefined(); expect(json._selectedZoomLevel).toBeUndefined(); }); it('serializes default values correctly', () => { const control = new ZoomSwitchControl(); const json = JSON.parse(JSON.stringify(control)); expect(json.orientation).toBe('horizontal'); expect(json.isAlwaysExpanded).toBe(false); expect(json.isExpanded).toBe(false); expect(json.accessibilityLabel).toBe('Zoom '); expect(json.accessibilityHint).toBe('Adjusts the camera zoom level'); }); it('still serializes legacy icon properties', () => { const control = new ZoomSwitchControl(); const json = JSON.parse(JSON.stringify(control)); expect(json.icon).toBeDefined(); expect(json.icon.zoomedOut).toBeDefined(); expect(json.icon.zoomedIn).toBeDefined(); }); }); }); describe('ZoomSwitchOrientation', () => { it('has correct string values for JSON serialization', () => { expect(ZoomSwitchOrientation.Horizontal).toBe('horizontal'); expect(ZoomSwitchOrientation.Vertical).toBe('vertical'); }); });