-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(xychart): add Annotations tests (#948)
* test(xychart/AnnotationLabel): add test * test(xychart): add Annotation tests
- Loading branch information
1 parent
f5b7f84
commit b6a455e
Showing
7 changed files
with
120 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { | ||
Annotation as VxAnnotation, | ||
EditableAnnotation as VxEditableAnnotation, | ||
} from '@visx/annotation'; | ||
import { DataContext, Annotation, AnimatedAnnotation } from '../../src'; | ||
import getDataContext from '../mocks/getDataContext'; | ||
|
||
const series = { key: 'visx', data: [{}], xAccessor: () => 4, yAccessor: () => 7 }; | ||
|
||
function setup(children: React.ReactNode) { | ||
return mount( | ||
<DataContext.Provider value={getDataContext(series)}> | ||
<svg>{children}</svg> | ||
</DataContext.Provider>, | ||
); | ||
} | ||
|
||
describe('<Annotation />', () => { | ||
it('should be defined', () => { | ||
expect(Annotation).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotation', () => { | ||
const wrapper = setup( | ||
<Annotation dataKey={series.key} datum={{}}> | ||
{'test'} | ||
</Annotation>, | ||
); | ||
expect(wrapper.find(VxAnnotation)).toHaveLength(1); | ||
}); | ||
it('should render a VxEditableAnnotation when editable=true', () => { | ||
const wrapper = setup( | ||
<Annotation editable dataKey={series.key} datum={{}}> | ||
{'test'} | ||
</Annotation>, | ||
); | ||
expect(wrapper.find(VxEditableAnnotation)).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
describe('<AnimatedAnnotation />', () => { | ||
it('should be defined', () => { | ||
expect(AnimatedAnnotation).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotation', () => { | ||
const wrapper = setup( | ||
<AnimatedAnnotation dataKey={series.key} datum={{}}> | ||
{'test'} | ||
</AnimatedAnnotation>, | ||
); | ||
expect(wrapper.find(VxAnnotation)).toHaveLength(1); | ||
}); | ||
it('should render a VxEditableAnnotation when editable=true', () => { | ||
const wrapper = setup( | ||
<AnimatedAnnotation editable dataKey={series.key} datum={{}}> | ||
{'test'} | ||
</AnimatedAnnotation>, | ||
); | ||
expect(wrapper.find(VxEditableAnnotation)).toHaveLength(1); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/visx-xychart/test/components/AnnotationCircleSubject.test.tsx
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { CircleSubject as VxAnnotationCircleSubject } from '@visx/annotation'; | ||
import { AnnotationCircleSubject } from '../../src'; | ||
|
||
describe('<AnnotationCircleSubject />', () => { | ||
it('should be defined', () => { | ||
expect(AnnotationCircleSubject).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotationCircleSubject', () => { | ||
const wrapper = shallow(<AnnotationCircleSubject />); | ||
expect(wrapper.find(VxAnnotationCircleSubject)).toHaveLength(1); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/visx-xychart/test/components/AnnotationConnector.test.tsx
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Connector as VxAnnotationConnector } from '@visx/annotation'; | ||
import { AnnotationConnector } from '../../src'; | ||
|
||
describe('<AnnotationConnector />', () => { | ||
it('should be defined', () => { | ||
expect(AnnotationConnector).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotationConnector', () => { | ||
const wrapper = shallow(<AnnotationConnector />); | ||
expect(wrapper.find(VxAnnotationConnector)).toHaveLength(1); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/visx-xychart/test/components/AnnotationLabel.test.tsx
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Label as VxAnnotationLabel } from '@visx/annotation'; | ||
import { AnnotationLabel } from '../../src'; | ||
|
||
describe('<AnnotationLabel />', () => { | ||
it('should be defined', () => { | ||
expect(AnnotationLabel).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotationLabel', () => { | ||
const wrapper = shallow(<AnnotationLabel />); | ||
expect(wrapper.find(VxAnnotationLabel)).toHaveLength(1); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/visx-xychart/test/components/AnnotationLineSubject.test.tsx
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { LineSubject as VxAnnotationLineSubject } from '@visx/annotation'; | ||
import { AnnotationLineSubject } from '../../src'; | ||
|
||
describe('<AnnotationLineSubject />', () => { | ||
it('should be defined', () => { | ||
expect(AnnotationLineSubject).toBeDefined(); | ||
}); | ||
it('should render a VxAnnotationLineSubject', () => { | ||
const wrapper = shallow(<AnnotationLineSubject />); | ||
expect(wrapper.find(VxAnnotationLineSubject)).toHaveLength(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
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