From 3ff1c351da8929ac356595d44dfc17e281bc28ee Mon Sep 17 00:00:00 2001 From: Victor Cazanave Date: Sat, 13 Apr 2019 16:51:10 +0800 Subject: [PATCH] [Tests] Update tests and comments --- __tests__/__snapshots__/svg-map.test.js.snap | 101 ++++++++++++++----- __tests__/checkbox-svg-map.test.js | 1 + __tests__/radio-svg-map.test.js | 2 +- __tests__/svg-map.test.js | 34 +++---- 4 files changed, 91 insertions(+), 47 deletions(-) diff --git a/__tests__/__snapshots__/svg-map.test.js.snap b/__tests__/__snapshots__/svg-map.test.js.snap index cd8c256..79bed18 100644 --- a/__tests__/__snapshots__/svg-map.test.js.snap +++ b/__tests__/__snapshots__/svg-map.test.js.snap @@ -2248,7 +2248,52 @@ exports[`SVGMap component Maps displays map of Utah 1`] = ` `; -exports[`SVGMap component Properties displays heat map with custom location css 1`] = ` +exports[`SVGMap component Properties displays map with custom function location props 1`] = ` + + + + +`; + +exports[`SVGMap component Properties displays map with custom props 1`] = ` - -`; - -exports[`SVGMap component Properties displays map with custom props 1`] = ` - + { let location = null; beforeEach(() => { + // TODO: Use fake map to simplify tests? wrapper = mount(); location = wrapper.find(locationSelector); }); diff --git a/__tests__/radio-svg-map.test.js b/__tests__/radio-svg-map.test.js index aaf2c63..2236d60 100644 --- a/__tests__/radio-svg-map.test.js +++ b/__tests__/radio-svg-map.test.js @@ -21,6 +21,7 @@ describe('RadioSVGMap component', () => { let nextLocation = null; beforeEach(() => { + // TODO: Use fake map to simplify tests? wrapper = mount(); location = wrapper.find(locationSelector); previousLocation = wrapper.find(previousLocationSelector); @@ -84,7 +85,6 @@ describe('RadioSVGMap component', () => { }); }); - // TODO: Add tests for first/last location and right/left arrow describe('Keyboard navigation', () => { test('selects focused unselected location when hitting spacebar', () => { expect(location.props()['aria-checked']).toBeFalsy(); diff --git a/__tests__/svg-map.test.js b/__tests__/svg-map.test.js index ca9fcbb..edf3188 100644 --- a/__tests__/svg-map.test.js +++ b/__tests__/svg-map.test.js @@ -8,9 +8,14 @@ describe('SVGMap component', () => { label: 'label', viewBox: 'viewBox', locations: [{ - name: 'name', - id: 'id', - path: 'path' + name: 'name0', + id: 'id0', + path: 'path0' + }, + { + name: 'name1', + id: 'id1', + path: 'path1' }] }; @@ -46,25 +51,13 @@ describe('SVGMap component', () => { expect(tree).toMatchSnapshot(); }); - test('displays heat map with custom location css', () => { - const eventHandler = () => 'eventHandler'; - const isLocationSelected = () => 'isLocationSelected'; - const generateHeat = () => 'svg-map__location heat0'; + test('displays map with custom function location props', () => { + const locationClassName = (location, index) => `locationClassName-${index}`; + const locationTabIndex = (location, index) => `locationTabIndex-${index}`; const component = renderer.create( ); const tree = component.toJSON(); @@ -73,7 +66,6 @@ describe('SVGMap component', () => { }); }); - describe('Maps', () => { test('displays map of Australia', () => { const component = renderer.create();