Skip to content

Commit

Permalink
Fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ndresx committed Oct 22, 2022
1 parent faf1b9f commit b09b19f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/Countdown.test.tsx
Expand Up @@ -56,7 +56,7 @@ describe('<Countdown />', () => {
const zeroPadTime = 0;

class Completionist extends React.Component<any> {
componentDidMount() { }
componentDidMount() {}

render() {
return (
Expand Down Expand Up @@ -168,7 +168,9 @@ describe('<Countdown />', () => {
const onStart = jest.fn().mockImplementation(() => calls.push('onStart'));
const onTick = jest.fn().mockImplementation(() => calls.push('onTick'));
const onComplete = jest.fn().mockImplementation(() => calls.push('onComplete'));
wrapper = mount(<Countdown date={countdownDate} onStart={onStart} onTick={onTick} onComplete={onComplete} />);
wrapper = mount(
<Countdown date={countdownDate} onStart={onStart} onTick={onTick} onComplete={onComplete} />
);

expect(calls).toEqual(['onStart']);

Expand All @@ -177,7 +179,7 @@ describe('<Countdown />', () => {
jest.runTimersToTime(1000);
}

expect(calls).toEqual(['onStart', ...(new Array(9).fill('onTick')), 'onComplete']);
expect(calls).toEqual(['onStart', ...new Array(9).fill('onTick'), 'onComplete']);
});

it('should trigger onComplete callback on start if date is in the past when countdown starts', () => {
Expand All @@ -188,7 +190,9 @@ describe('<Countdown />', () => {
const onComplete = jest.fn().mockImplementation(() => calls.push('onComplete'));

countdownDate = Date.now() - 10000;
wrapper = mount(<Countdown date={countdownDate} onStart={onStart} onTick={onTick} onComplete={onComplete} />);
wrapper = mount(
<Countdown date={countdownDate} onStart={onStart} onTick={onTick} onComplete={onComplete} />
);

expect(onStart).toHaveBeenCalledTimes(1);
expect(onTick).not.toHaveBeenCalled();
Expand Down Expand Up @@ -635,6 +639,6 @@ describe('<Countdown />', () => {
afterEach(() => {
try {
wrapper.detach();
} catch (e) { }
} catch (e) {}
});
});
11 changes: 7 additions & 4 deletions src/Countdown.tsx
Expand Up @@ -14,8 +14,8 @@ import {

export interface CountdownProps
extends React.Props<Countdown>,
CountdownTimeDeltaFormatOptions,
Omit<LegacyCountdownProps, 'onComplete'> {
CountdownTimeDeltaFormatOptions,
Omit<LegacyCountdownProps, 'onComplete'> {
readonly date?: Date | number | string;
readonly controlled?: boolean;
readonly intervalDelay?: number;
Expand All @@ -31,7 +31,10 @@ export interface CountdownProps
readonly onPause?: CountdownTimeDeltaFn;
readonly onStop?: CountdownTimeDeltaFn;
readonly onTick?: CountdownTimeDeltaFn;
readonly onComplete?: (timeDelta: CountdownTimeDelta, completedOnStart: boolean) => void | LegacyCountdownProps['onComplete'];
readonly onComplete?: (
timeDelta: CountdownTimeDelta,
completedOnStart: boolean
) => void | LegacyCountdownProps['onComplete'];
}

export interface CountdownRenderProps extends CountdownTimeDelta {
Expand Down Expand Up @@ -262,7 +265,7 @@ export default class Countdown extends React.Component<CountdownProps, Countdown

const onDone = () => {
if (callback) callback(this.state.timeDelta);

if (this.props.onComplete && (completing || completedOnStart)) {
this.props.onComplete(timeDelta, completedOnStart);
}
Expand Down

0 comments on commit b09b19f

Please sign in to comment.