Skip to content

Commit

Permalink
test: update useRiveFile tests to check buffer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
damzobridge committed May 24, 2024
1 parent 0e377bd commit eaa0bdc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/useRiveFile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('useRiveFile', () => {
expect(riveInstance?.cleanup).toHaveBeenCalled();
});

it('does not reinitialize RiveFile if params do not change', async () => {
it('does not reinitialize RiveFile if src has not changed', async () => {
const params = {
src: 'file-src',
enableRiveAssetCDN: false
Expand All @@ -57,6 +57,19 @@ describe('useRiveFile', () => {
expect(RiveFile).toHaveBeenCalledTimes(1);
});

it('does not reinitialize RiveFile if buffer has not changed', async () => {
const params = {
buffer: new ArrayBuffer(10),
enableRiveAssetCDN: false
};

const { rerender } = renderHook(() => useRiveFile(params));

rerender();

expect(RiveFile).toHaveBeenCalledTimes(1);
});

it('reinitializes RiveFile if src changes', async () => {
let params = {
src: 'file-src',
Expand Down

0 comments on commit eaa0bdc

Please sign in to comment.