diff --git a/packages/core/test/replay/CustomMask.test.ts b/packages/core/test/replay/CustomMask.test.ts new file mode 100644 index 000000000..75d6d589d --- /dev/null +++ b/packages/core/test/replay/CustomMask.test.ts @@ -0,0 +1,58 @@ +import { describe, expect, it, beforeEach } from '@jest/globals'; + +describe('CustomMask', () => { + beforeEach(() => { + jest.resetModules(); + }); + + it('returns a fallback when native view manager is missing', () => { + jest.mock('react-native', () => ({ + UIManager: {}, + View: jest.fn(), + })); + + const { Mask, Unmask } = require('../../src/js/replay/CustomMask'); + + expect(Mask).toBeDefined(); + expect(Unmask).toBeDefined(); + }); + + it('returns a fallback component when native view manager config is missing', () => { + jest.mock('react-native', () => ({ + UIManager: { + hasViewManagerConfig: () => false, + }, + View: jest.fn(), + })); + + const { Mask, Unmask } = require('../../src/js/replay/CustomMask'); + + expect(Mask).toBeDefined(); + expect(Unmask).toBeDefined(); + }); + + it('returns native components when native components exist', () => { + const mockMaskComponent = jest.fn(); + const mockUnmaskComponent = jest.fn(); + + jest.mock('../../src/js/RNSentryReplayMaskNativeComponent', () => ({ + default: mockMaskComponent, + })); + + jest.mock('../../src/js/RNSentryReplayUnmaskNativeComponent', () => ({ + default: mockUnmaskComponent, + })); + + jest.mock('react-native', () => ({ + UIManager: { + hasViewManagerConfig: () => true, + }, + View: jest.fn(), + })); + + const { Mask, Unmask } = require('../../src/js/replay/CustomMask'); + + expect(Mask).toBe(mockMaskComponent); + expect(Unmask).toBe(mockUnmaskComponent); + }); +}); diff --git a/packages/core/test/replay/CustomMask.web.test.ts b/packages/core/test/replay/CustomMask.web.test.ts new file mode 100644 index 000000000..1ee8d61e9 --- /dev/null +++ b/packages/core/test/replay/CustomMask.web.test.ts @@ -0,0 +1,10 @@ +import { describe } from '@jest/globals'; + +describe('CustomMask', () => { + it('returns a react native view', () => { + const { Mask, Unmask } = require('../../src/js/replay/CustomMask'); + + expect(Mask).toBeDefined(); + expect(Unmask).toBeDefined(); + }); +});