Gitako/src/components/Highlight.test.tsx
2022-06-06 23:44:44 +08:00

15 lines
499 B
TypeScript

import { render } from '@testing-library/react'
import React, { ComponentProps } from 'react'
import { Highlight } from './Highlight'
function test(title: string, text: string, match?: ComponentProps<typeof Highlight>['match']) {
it(title, () => {
expect(render(<Highlight text={text} match={match} />).container.textContent).toBe(text)
})
}
test('sample', 'abc', undefined)
test('sample', 'abc', /./)
test('sample', 'abc', /../)
test('sample', 'abc', /.../)
test('sample', 'abc', /..../)