Skip to content

Commit

Permalink
Fix types and defaults
Browse files Browse the repository at this point in the history
- set Props "run" to be optional.
- fix test-utils
  • Loading branch information
gilbarbara committed Sep 10, 2024
1 parent d7febf7 commit 805356c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Joyride extends React.Component<Props, State> {
constructor(props: Props) {
super(props);

const { debug, getHelpers, run, stepIndex } = props;
const { debug, getHelpers, run = true, stepIndex } = props;

this.store = createStore({
...props,
Expand Down
8 changes: 4 additions & 4 deletions src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { noop } from '~/modules/helpers';

import { Locale } from '~/types';
import { FloaterProps, Locale, Props, Step } from '~/types';

export const defaultFloaterProps = {
export const defaultFloaterProps: FloaterProps = {
options: {
preventOverflow: {
boundariesElement: 'scrollParent',
Expand Down Expand Up @@ -43,7 +43,7 @@ export const defaultStep = {
showSkipButton: false,
spotlightClicks: false,
spotlightPadding: 10,
};
} satisfies Omit<Step, 'content' | 'target'>;

export const defaultProps = {
continuous: false,
Expand All @@ -64,4 +64,4 @@ export const defaultProps = {
spotlightClicks: false,
spotlightPadding: 10,
steps: [],
};
} satisfies Props;
4 changes: 3 additions & 1 deletion src/types/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export type Props = Simplify<
* Run/stop the tour.
* @default true
*/
run: boolean;
run?: boolean;
/**
* The duration for scroll to element.
* @default 300
Expand Down Expand Up @@ -378,3 +378,5 @@ export type TooltipRenderProps = Simplify<
};
}
>;

export type { Props as FloaterProps } from 'react-floater';
3 changes: 1 addition & 2 deletions test/__fixtures__/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
queryHelpers,
render,
RenderOptions,
screen,
within,
} from '@testing-library/react';

Expand Down Expand Up @@ -41,7 +40,7 @@ const allQueries = {
...customQueries,
};

const customScreen = { ...screen, ...within(document.body, allQueries) };
const customScreen = within(document.body, allQueries);
const customWithin = (element: HTMLElement) => within(element, allQueries);
const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>) =>
render(ui, { queries: allQueries, ...options });
Expand Down

0 comments on commit 805356c

Please sign in to comment.