-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor types w/ generics and add use functional components (#13)
- Loading branch information
Showing
13 changed files
with
1,744 additions
and
150 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
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,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: ['/node_modules/', '/.docz/', '/lib/'], | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react' | ||
import React from 'react' | ||
|
||
export interface MarkProps { | ||
key: string | ||
|
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
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,24 @@ | ||
import React from 'react' | ||
import TextAnnotator from '../TextAnnotator' | ||
import {render, fireEvent} from '@testing-library/react' | ||
|
||
test('renders without getSpan', () => { | ||
render( | ||
<TextAnnotator | ||
content="Foo bar baz" | ||
value={[{start: 0, end: 5, tag: 'PERSON', text: 'foo', extra: 1}]} | ||
onChange={() => {}} | ||
/> | ||
) | ||
}) | ||
|
||
test('renders when value and getSpan return match', () => { | ||
render( | ||
<TextAnnotator | ||
content="Foo bar baz" | ||
value={[{start: 0, end: 5, tag: 'PERSON', text: 'foo', extra: 1}]} | ||
onChange={() => {}} | ||
getSpan={span => ({...span, tag: 'FOO', text: 'foo', extra: 1})} | ||
/> | ||
) | ||
}) |
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,24 @@ | ||
import React from 'react' | ||
import {render} from '@testing-library/react' | ||
import TokenAnnotator from '../TokenAnnotator' | ||
|
||
test('renders without getSpan', () => { | ||
render( | ||
<TokenAnnotator | ||
tokens={['Foo', 'Bar', 'Baz']} | ||
value={[{start: 0, end: 5, tag: 'PERSON', tokens: [], extra: 1}]} | ||
onChange={() => {}} | ||
/> | ||
) | ||
}) | ||
|
||
test('renders when value and getSpan return match', () => { | ||
render( | ||
<TokenAnnotator | ||
tokens={['Foo', 'Bar', 'Baz']} | ||
value={[{start: 0, end: 1, tag: 'PERSON', tokens: ['Foo'], extra: 1}]} | ||
onChange={() => {}} | ||
getSpan={span => ({...span, tag: 'FOO', tokens: ['Foo'], extra: 1})} | ||
/> | ||
) | ||
}) |
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,4 @@ | ||
export type Span = { | ||
start: number | ||
end: number | ||
} |
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
Oops, something went wrong.