-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aeff39b
commit cbb1d4e
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/bezier-react/src/features/SmoothCornersFeature/SmoothCornersFeatures.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |