-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
195 additions
and
139 deletions.
There are no files selected for viewing
28 changes: 14 additions & 14 deletions
28
packages/react-jsx-highmaps/test/components/HighchartsMapChart/HighchartsMapChart.spec.js
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,55 +1,55 @@ | ||
import React from 'react'; | ||
import { BaseChart, HighchartsContext } from 'react-jsx-highcharts'; | ||
|
||
jest.mock('react-jsx-highcharts', () => ({ | ||
...jest.requireActual('react-jsx-highcharts'), | ||
useHighcharts: jest.fn() | ||
})); | ||
|
||
import { useHighcharts, BaseChart } from 'react-jsx-highcharts'; | ||
import { Highcharts, createMockChart } from '../../test-utils'; | ||
import HighchartsMapChart from '../../../src/components/HighchartsMapChart/HighchartsMapChart'; | ||
|
||
describe('<HighchartsMapChart />', () => { | ||
let testContext; | ||
let ProvidedHighchartsMapChart; | ||
|
||
beforeEach(() => { | ||
testContext = {}; | ||
const chart = createMockChart(); | ||
Highcharts.mapChart.mockReturnValue(chart); | ||
|
||
ProvidedHighchartsMapChart = props => ( | ||
<HighchartsContext.Provider value={Highcharts}> | ||
<HighchartsMapChart {...props} /> | ||
</HighchartsContext.Provider> | ||
) | ||
useHighcharts.mockImplementation(() => Highcharts); | ||
}); | ||
|
||
afterEach(() => { | ||
Highcharts.mapChart.mockRestore() | ||
}); | ||
|
||
it('renders a <BaseChart />', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart />); | ||
const wrapper = mount(<HighchartsMapChart />); | ||
expect(wrapper.find(BaseChart)).toExist(); | ||
}); | ||
|
||
it('renders a <BaseChart /> with the correct creation function', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart />); | ||
const wrapper = mount(<HighchartsMapChart />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chartCreationFunc',Highcharts.mapChart); | ||
}); | ||
|
||
it('renders a <BaseChart /> with the correct chart type', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart />); | ||
const wrapper = mount(<HighchartsMapChart />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chartType','mapChart'); | ||
}); | ||
|
||
it('renders a <BaseChart /> with GeoJSON from a string', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart map='mock/map' />); | ||
const wrapper = mount(<HighchartsMapChart map='mock/map' />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chart',{ map: { some: 'data' } }); | ||
}) | ||
|
||
it('renders a <BaseChart /> with direct GeoJSON', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart map={{ direct: 'input' }} />); | ||
const wrapper = mount(<HighchartsMapChart map={{ direct: 'input' }} />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chart',{ map: { direct: 'input' } }); | ||
}) | ||
|
||
it('passes other props through to <BaseChart />', () => { | ||
const wrapper = mount(<ProvidedHighchartsMapChart plotOptions={{ c: 'd' }} />); | ||
const wrapper = mount(<HighchartsMapChart plotOptions={{ c: 'd' }} />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('plotOptions',{ c: 'd' }); | ||
}); | ||
}); |
31 changes: 17 additions & 14 deletions
31
...ges/react-jsx-highstock/test/components/HighchartsStockChart/HighchartsStockChart.spec.js
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,39 +1,42 @@ | ||
import React from 'react'; | ||
import { BaseChart, HighchartsContext } from 'react-jsx-highcharts'; | ||
|
||
jest.mock('react-jsx-highcharts', () => ({ | ||
...jest.requireActual('react-jsx-highcharts'), | ||
useHighcharts: jest.fn() | ||
})); | ||
|
||
import { useHighcharts, BaseChart } from 'react-jsx-highcharts'; | ||
import { Highcharts, createMockChart } from '../../test-utils'; | ||
import HighchartsStockChart from '../../../src/components/HighchartsStockChart/HighchartsStockChart'; | ||
|
||
describe('<HighchartsStockChart />', () => { | ||
let ProvidedHighchartsStockChart; | ||
|
||
beforeEach(() => { | ||
const chart = createMockChart(); | ||
Highcharts.stockChart.mockReturnValue(chart); | ||
|
||
ProvidedHighchartsStockChart = props => ( | ||
<HighchartsContext.Provider value={ Highcharts }> | ||
<HighchartsStockChart {...props} /> | ||
</HighchartsContext.Provider> | ||
) | ||
useHighcharts.mockImplementation(() => Highcharts); | ||
}); | ||
|
||
it('renders a <BaseChart />', () => { | ||
const wrapper = mount(<ProvidedHighchartsStockChart />); | ||
const wrapper = mount(<HighchartsStockChart />); | ||
expect(wrapper.find(BaseChart)).toExist(); | ||
}); | ||
|
||
it('renders a <BaseChart /> with the correct creation function', () => { | ||
const wrapper = mount(<ProvidedHighchartsStockChart />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chartCreationFunc', Highcharts.stockChart); | ||
const wrapper = mount(<HighchartsStockChart />); | ||
expect(wrapper.find(BaseChart)).toHaveProp( | ||
'chartCreationFunc', | ||
Highcharts.stockChart | ||
); | ||
}); | ||
|
||
it('renders a <BaseChart /> with the correct chart type', () => { | ||
const wrapper = mount(<ProvidedHighchartsStockChart />); | ||
const wrapper = mount(<HighchartsStockChart />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('chartType', 'stockChart'); | ||
}); | ||
|
||
it('passes other props through to <BaseChart />', () => { | ||
const wrapper = mount(<ProvidedHighchartsStockChart plotOptions={{ c: 'd' }} />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('plotOptions',{ c: 'd' }); | ||
const wrapper = mount(<HighchartsStockChart plotOptions={{ c: 'd' }} />); | ||
expect(wrapper.find(BaseChart)).toHaveProp('plotOptions', { c: 'd' }); | ||
}); | ||
}); |
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.