This file contains hidden or 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
type Wrapper = (props: { children: JSX.Element }) => JSX.Element; | |
export function combineWrappers(...wrappers: Wrapper[]): Wrapper { | |
return function wrapper({ children }: { children: JSX.Element }) { | |
return wrappers.reduce((acc, curr) => { | |
const CurrentWrapper = curr; | |
return <CurrentWrapper>{acc}</CurrentWrapper>; | |
}, children); | |
}; |
This file contains hidden or 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
export default function filterEmptyValues<T>(list: (T | null | undefined)[]): T[] { | |
return list.reduce<T[]>( | |
(acc: T[], curr: T | null | undefined) => | |
curr !== undefined && curr !== null ? [...acc, curr] : acc, | |
[] | |
); | |
} |
This file contains hidden or 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
import React, { ComponentType } from "react"; | |
export type ConfigProps = { | |
config: string; | |
} | |
export function withConfig<T>(WrappedComponent: ComponentType<T & ConfigProps>) { | |
return function Wrapper(props: T) { | |
const config = 'some config'; | |
This file contains hidden or 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
import React from 'react'; | |
import { render, act } from '@testing-library/react'; | |
import TextSecondTimer from './TextSecondTimer'; | |
describe('Text second timer component', () => { | |
beforeEach(() => jest.useFakeTimers()); | |
it('shows zero if timeout is zero', () => { | |
const { getByText } = render(<TextSecondTimer timeoutInSeconds={0} />); |