forked from tomcru/holy-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skipReplaceTransitions prop to HolyLoader
Fixes tomcru#23 Add `skipReplaceTransitions` prop to `HolyLoader` component to skip loader for `replaceState` transitions. * **src/index.tsx** - Add `skipReplaceTransitions` prop to `HolyLoaderProps` interface. - Update `HolyLoader` component to handle `skipReplaceTransitions` prop. - Skip loader for `replaceState` transitions when `skipReplaceTransitions` is true. * **README.md** - Add `skipReplaceTransitions` prop to the API section. * **src/__tests__/holyLoader.test.ts** - Add tests to verify the behavior of `skipReplaceTransitions` prop.
- Loading branch information
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
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
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,35 @@ | ||
import { describe, expect, it, vi } from 'vitest'; | ||
import { HolyLoaderProps } from '../index'; | ||
import HolyLoader from '../index'; | ||
|
||
describe('HolyLoader', () => { | ||
it('should skip loader for replaceState transitions when skipReplaceTransitions is true', () => { | ||
const props: HolyLoaderProps = { | ||
skipReplaceTransitions: true, | ||
}; | ||
|
||
const holyLoader = new HolyLoader(props); | ||
|
||
const startSpy = vi.spyOn(holyLoader, 'start'); | ||
const completeSpy = vi.spyOn(holyLoader, 'complete'); | ||
|
||
history.replaceState({}, '', '/new-url'); | ||
expect(startSpy).not.toHaveBeenCalled(); | ||
expect(completeSpy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not skip loader for replaceState transitions when skipReplaceTransitions is false', () => { | ||
const props: HolyLoaderProps = { | ||
skipReplaceTransitions: false, | ||
}; | ||
|
||
const holyLoader = new HolyLoader(props); | ||
|
||
const startSpy = vi.spyOn(holyLoader, 'start'); | ||
const completeSpy = vi.spyOn(holyLoader, 'complete'); | ||
|
||
history.replaceState({}, '', '/new-url'); | ||
expect(startSpy).toHaveBeenCalled(); | ||
expect(completeSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
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