diff --git a/packages/bezier-react/src/features/SmoothCornersFeature/SmoothCornersFeatures.test.ts b/packages/bezier-react/src/features/SmoothCornersFeature/SmoothCornersFeatures.test.ts new file mode 100644 index 0000000000..ed65dbf7d7 --- /dev/null +++ b/packages/bezier-react/src/features/SmoothCornersFeature/SmoothCornersFeatures.test.ts @@ -0,0 +1,34 @@ +import SmoothCornersFeature from './SmoothCornersFeature' + +describe('SmoothCornersFeature', () => { + let addModule: jest.Mock + + beforeEach(() => { + addModule = jest.fn(() => Promise.resolve()) + + Object.defineProperty(global, 'URL', { + value: { + createObjectURL: jest.fn(), + }, + }) + + Object.defineProperty(global, 'CSS', { + value: { + paintWorklet: { addModule }, + }, + }) + }) + + it('If the global objects are the same, activate should only be executed once.', async () => { + await SmoothCornersFeature.activate(globalThis) + await SmoothCornersFeature.activate(globalThis) + expect(addModule).toHaveBeenCalledTimes(1) + }) + + it('If the global object has changed, activate should be executed again.', async () => { + await SmoothCornersFeature.activate(globalThis) + expect(addModule).toHaveBeenCalledTimes(0) + await SmoothCornersFeature.activate({ ...globalThis }) + expect(addModule).toHaveBeenCalledTimes(1) + }) +})