Skip to content

Commit 39a638e

Browse files
authored
fix: eslint errors (#92)
* fix: eslint by droping use from non-hooks and fixing jest titles * fix: typo in test title
1 parent 8895031 commit 39a638e

13 files changed

+44
-44
lines changed

src/components/AzureMap/AzureMap.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { AzureMapsContext } from '../../contexts/AzureMapContext'
44
import AzureMap from './AzureMap'
55
import { Map } from 'azure-maps-control'
66
import { IAzureMap, IAzureMapsContextProps } from '../../types'
7-
import { useCreateImageSprites } from './useCreateSprites'
8-
import { useCreateMapCustomControls, useCreateMapControls } from './useCreateMapControls'
7+
import { createImageSprites } from './useCreateSprites'
8+
import { createMapCustomControls, createMapControls } from './useCreateMapControls'
99

1010
const LoaderComponent = () => <div>Loader</div>
1111

1212
jest.mock('./useCreateMapControls', () => {
1313
return {
14-
useCreateMapCustomControls: jest.fn(),
15-
useCreateMapControls: jest.fn()
14+
createMapCustomControls: jest.fn(),
15+
createMapControls: jest.fn()
1616
}
1717
})
1818

@@ -108,25 +108,25 @@ describe('AzureMap Component', () => {
108108
expect(mapContextProps.removeMapRef).toHaveBeenCalled()
109109
})
110110

111-
it('should call useCreateImageSprites if imageSprites is not falsy', () => {
111+
it('should call createImageSprites if imageSprites is not falsy', () => {
112112
const mapRef = new Map('fake', {})
113113
render(
114114
wrapWithAzureMapContext(
115115
{ ...mapContextProps, mapRef },
116116
{ imageSprites: [{ id: 'some_fake_id' }] }
117117
)
118118
)
119-
expect(useCreateImageSprites).toHaveBeenCalled()
119+
expect(createImageSprites).toHaveBeenCalled()
120120
})
121121

122-
it('should call useCreateMapControls if controls is not falsy', () => {
122+
it('should call createMapControls if controls is not falsy', () => {
123123
const mapRef = new Map('fake', {})
124124
const fakeControls = [{ controlName: 'fake_control_name' }]
125125
render(wrapWithAzureMapContext({ ...mapContextProps, mapRef }, { controls: fakeControls }))
126-
expect(useCreateMapControls).toHaveBeenCalledWith(expect.any(Object), fakeControls)
126+
expect(createMapControls).toHaveBeenCalledWith(expect.any(Object), fakeControls)
127127
})
128128

129-
it('should call useCreateMapCustomControls if customControls is not falsy', () => {
129+
it('should call createMapCustomControls if customControls is not falsy', () => {
130130
const mapRef = new Map('fake', {})
131131
const customControls = [
132132
{
@@ -142,7 +142,7 @@ describe('AzureMap Component', () => {
142142
}
143143
)
144144
)
145-
expect(useCreateMapCustomControls).toHaveBeenCalledWith(expect.any(Object), customControls)
145+
expect(createMapCustomControls).toHaveBeenCalledWith(expect.any(Object), customControls)
146146
})
147147

148148
it('should setTraffic on initial props', () => {

src/components/AzureMap/AzureMap.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { Guid } from 'guid-typescript'
66
import 'azure-maps-control/dist/atlas.min.css'
77
import 'mapbox-gl/src/css/mapbox-gl.css'
88
import { useCheckRef } from '../../hooks/useCheckRef'
9-
import { useCreateImageSprites } from './useCreateSprites'
10-
import { useCreateMapControls, useCreateMapCustomControls } from './useCreateMapControls'
9+
import { createImageSprites } from './useCreateSprites'
10+
import { createMapControls, createMapCustomControls } from './useCreateMapControls'
1111

1212
const AzureMap = memo(
1313
({
@@ -64,13 +64,13 @@ const AzureMap = memo(
6464
useCheckRef<MapType, MapType>(mapRef, mapRef, mref => {
6565
mref.events.add('ready', () => {
6666
if (imageSprites) {
67-
useCreateImageSprites(mref, imageSprites)
67+
createImageSprites(mref, imageSprites)
6868
}
6969
if (controls) {
70-
useCreateMapControls(mref, controls)
70+
createMapControls(mref, controls)
7171
}
7272
if (customControls) {
73-
useCreateMapCustomControls(mref, customControls)
73+
createMapCustomControls(mref, customControls)
7474
}
7575
if (trafficOptions) {
7676
mref.setTraffic(trafficOptions)

src/components/AzureMap/useCreateMapControl.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { renderHook } from '@testing-library/react-hooks'
22
import {
33
createControl,
4-
useCreateMapControls,
5-
useCreateMapCustomControls
4+
createMapControls,
5+
createMapCustomControls
66
} from './useCreateMapControls'
77
import { Map } from 'azure-maps-control'
88
import { IAzureMapControls, IAzureCustomControls } from '../../types'
@@ -34,7 +34,7 @@ describe('Control hooks', () => {
3434
it('should create two map controls and call proper method', () => {
3535
const mockMap = new Map('#fake-container', {})
3636
mockMap.controls.add = jest.fn()
37-
renderHook(() => useCreateMapControls(mockMap, fakeDefaultControls))
37+
renderHook(() => createMapControls(mockMap, fakeDefaultControls))
3838
expect(mockMap.controls.add).toHaveBeenCalledWith(
3939
{ compassOption: 'option' },
4040
fakeDefaultControls[0].options
@@ -46,11 +46,11 @@ describe('Control hooks', () => {
4646
})
4747
})
4848

49-
describe('useCreateMapCustomControls tests', () => {
49+
describe('createMapCustomControls tests', () => {
5050
it('should create custom map controls and call proper method', () => {
5151
const mockMap = new Map('#fake-container', {})
5252
mockMap.controls.add = jest.fn()
53-
renderHook(() => useCreateMapCustomControls(mockMap, fakeCustomControlls))
53+
renderHook(() => createMapCustomControls(mockMap, fakeCustomControlls))
5454
expect(mockMap.controls.add).toHaveBeenCalledTimes(1)
5555
expect(mockMap.controls.add).toHaveBeenCalledWith(
5656
fakeCustomControlls[0].control,

src/components/AzureMap/useCreateMapControls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import atlas, {
1010

1111

1212

13-
export const useCreateMapControls = (mapRef: MapType, controls: IAzureMapControls[]) => {
13+
export const createMapControls = (mapRef: MapType, controls: IAzureMapControls[]) => {
1414
controls.forEach((control: IAzureMapControls) => {
1515
const { controlName, options, controlOptions } = control
1616
mapRef.controls.add(
@@ -42,7 +42,7 @@ export const createControl = (
4242
}
4343
}
4444

45-
export const useCreateMapCustomControls = (
45+
export const createMapCustomControls = (
4646
mapRef: MapType,
4747
customControls: IAzureCustomControls[]
4848
) => {

src/components/AzureMap/useCreateSprites.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { renderHook } from '@testing-library/react-hooks'
2-
import { useCreateImageSprites } from './useCreateSprites'
2+
import { createImageSprites } from './useCreateSprites'
33
import { Map } from 'azure-maps-control'
44

5-
describe('useCreateImageSprites tests', () => {
5+
describe('createImageSprites tests', () => {
66
it('should create image sprintes with icon field and call proper methods', async () => {
77
const mockMap = new Map('#fake-container', {})
88
const fakeImageSprite = {
@@ -13,7 +13,7 @@ describe('useCreateImageSprites tests', () => {
1313
secondaryColor: 'color',
1414
scale: 1
1515
}
16-
const { result } = renderHook(() => useCreateImageSprites(mockMap, [fakeImageSprite]))
16+
const { result } = renderHook(() => createImageSprites(mockMap, [fakeImageSprite]))
1717
await result.current
1818
expect(mockMap.imageSprite.add).toHaveBeenCalledWith('id', 'icon')
1919
expect(mockMap.imageSprite.createFromTemplate).toHaveBeenCalledWith(
@@ -34,7 +34,7 @@ describe('useCreateImageSprites tests', () => {
3434
secondaryColor: 'color',
3535
scale: 1
3636
}
37-
const { result } = renderHook(() => useCreateImageSprites(mockMap, [fakeImageSprite]))
37+
const { result } = renderHook(() => createImageSprites(mockMap, [fakeImageSprite]))
3838
await result.current
3939
expect(mockMap.imageSprite.add).not.toHaveBeenCalled()
4040
expect(mockMap.imageSprite.createFromTemplate).toHaveBeenCalledWith(
@@ -54,7 +54,7 @@ describe('useCreateImageSprites tests', () => {
5454
secondaryColor: 'color',
5555
scale: 1
5656
}
57-
const { result } = renderHook(() => useCreateImageSprites(mockMap, [fakeImageSprite]))
57+
const { result } = renderHook(() => createImageSprites(mockMap, [fakeImageSprite]))
5858
await result.current
5959
expect(mockMap.imageSprite.add).not.toHaveBeenCalled()
6060
expect(mockMap.imageSprite.createFromTemplate).toHaveBeenCalledWith(

src/components/AzureMap/useCreateSprites.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IAzureMapImageSprite, MapType } from '../../types'
22

3-
export const useCreateImageSprites = async (
3+
export const createImageSprites = async (
44
mapRef: MapType,
55
spriteArray: IAzureMapImageSprite[]
66
) => {

src/components/AzureMapFeature/AzureMapFeature.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import atlas from 'azure-maps-control'
99

1010
jest.mock('./useFeature')
1111
jest.mock('./useCreateAzureMapFeature.ts', () => ({
12-
useCreateAzureMapFeature: () => ({})
12+
createAzureMapFeature: () => ({})
1313
}))
1414

1515
const mapRef = new Map('fake', {})

src/components/AzureMapFeature/AzureMapFeature.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import atlas from 'azure-maps-control'
33

44
import { FeatureType, IAzureMapDataSourceProps, IAzureMapFeature, ShapeType } from '../../types'
55
import { AzureMapDataSourceContext } from '../../contexts/AzureMapDataSourceContext'
6-
import { useCreateAzureMapFeature } from './useCreateAzureMapFeature'
6+
import { createAzureMapFeature } from './useCreateAzureMapFeature'
77
import { useFeature } from './useFeature'
88

99
const AzureMapFeature = memo((props: IAzureMapFeature) => {
@@ -15,7 +15,7 @@ const AzureMapFeature = memo((props: IAzureMapFeature) => {
1515
useFeature(props, dataSourceRef, shapeRef, featureRef)
1616

1717
useEffect(() => {
18-
const featureSource: atlas.data.Geometry | undefined = useCreateAzureMapFeature(props)
18+
const featureSource: atlas.data.Geometry | undefined = createAzureMapFeature(props)
1919

2020
if ((!featureRef || !shapeRef) && featureSource) {
2121
switch (variant) {

src/components/AzureMapFeature/useCreateAzureMapFeature.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import atlas from 'azure-maps-control'
22
import { IAzureMapFeature } from '../../types'
3-
import { useCreateAzureMapFeature } from './useCreateAzureMapFeature'
3+
import { createAzureMapFeature } from './useCreateAzureMapFeature'
44

55
const fakeCoordinate: atlas.data.Position = new atlas.data.Position(10, 10)
66
const fakeCoordinates: atlas.data.Position[] = [
@@ -20,13 +20,13 @@ const fakeBbox: atlas.data.BoundingBox = new atlas.data.BoundingBox(
2020
)
2121

2222
describe('AzureMapFeature hooks', () => {
23-
describe('useCreateAzureMapFeature tests', () => {
23+
describe('createAzureMapFeature tests', () => {
2424
it('should return Point if type equal Point', () => {
2525
const pointProps: IAzureMapFeature = {
2626
type: 'Point',
2727
coordinate: fakeCoordinate
2828
}
29-
const createPoint = useCreateAzureMapFeature(pointProps)
29+
const createPoint = createAzureMapFeature(pointProps)
3030
expect(createPoint).toEqual({ coords: [10, 10], type: 'Point' })
3131
})
3232
it('should return MultiPoint if type equal MultiPoint', () => {
@@ -35,7 +35,7 @@ describe('AzureMapFeature hooks', () => {
3535
coordinates: fakeCoordinates,
3636
bbox: fakeBbox
3737
}
38-
const createMultiPoint = useCreateAzureMapFeature(multiPointProps)
38+
const createMultiPoint = createAzureMapFeature(multiPointProps)
3939
expect(createMultiPoint).toEqual({
4040
bbox: [
4141
[10, 10],
@@ -54,7 +54,7 @@ describe('AzureMapFeature hooks', () => {
5454
coordinates: fakeCoordinates,
5555
bbox: fakeBbox
5656
}
57-
const createLineString = useCreateAzureMapFeature(lineStringProps)
57+
const createLineString = createAzureMapFeature(lineStringProps)
5858
expect(createLineString).toEqual({
5959
bbox: [
6060
[10, 10],
@@ -73,7 +73,7 @@ describe('AzureMapFeature hooks', () => {
7373
multipleCoordinates: fakeMultipleCoordinates,
7474
bbox: fakeBbox
7575
}
76-
const createMultiLineStringProps = useCreateAzureMapFeature(multiLineStringProps)
76+
const createMultiLineStringProps = createAzureMapFeature(multiLineStringProps)
7777
expect(createMultiLineStringProps).toEqual({
7878
bbox: [
7979
[10, 10],
@@ -89,7 +89,7 @@ describe('AzureMapFeature hooks', () => {
8989
coordinates: fakeCoordinates,
9090
bbox: fakeBbox
9191
}
92-
const createLineString = useCreateAzureMapFeature(lineStringProps)
92+
const createLineString = createAzureMapFeature(lineStringProps)
9393
expect(createLineString).toEqual({
9494
bbox: [
9595
[10, 10],
@@ -108,7 +108,7 @@ describe('AzureMapFeature hooks', () => {
108108
multipleDimensionCoordinates: fakeMultipleDimensionCoordinates,
109109
bbox: fakeBbox
110110
}
111-
const createMultiPolygon = useCreateAzureMapFeature(multiPolygonProps)
111+
const createMultiPolygon = createAzureMapFeature(multiPolygonProps)
112112
expect(createMultiPolygon).toEqual({
113113
bbox: [
114114
[10, 10],

src/components/AzureMapFeature/useCreateAzureMapFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IAzureMapFeature } from '../../types'
22
import atlas from 'azure-maps-control'
33

4-
export const useCreateAzureMapFeature = ({
4+
export const createAzureMapFeature = ({
55
type,
66
coordinate,
77
coordinates,

src/components/AzureMapMarkers/AzureMapHtmlMarker/AzureMapHtmlMarker.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('AzureMaphtmlMarker tests', () => {
7575
expect(markerRef.setOptions).toHaveBeenCalledWith({ option: 'option' })
7676
})
7777

78-
it('should call setOptions on markerRef', () => {
78+
it('should call setOptions on markerRef when marketContent prop is passed', () => {
7979
markerRef.setOptions = jest.fn()
8080
render(wrapWithAzureMapContext({ markerContent: <div /> }))
8181
expect(markerRef.setOptions).toHaveBeenCalledWith({ htmlContent: '<div></div>' })

src/components/AzureMapPopup/AzureMapPopup.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('AzureMapPopup tests', () => {
5757
expect(mapRef.popups.remove).toHaveBeenCalled()
5858
})
5959

60-
it('should ropen popup when isVisible is true and isOpen returns false', () => {
60+
it('should open popup when isVisible is true and isOpen returns false', () => {
6161
popupRef.isOpen = jest.fn(() => false)
6262
render(
6363
wrapWithAzureMapContext({
@@ -68,7 +68,7 @@ describe('AzureMapPopup tests', () => {
6868
expect(popupRef.open).toHaveBeenCalledWith(mapRef)
6969
})
7070

71-
it('should ropen popup when isVisible is true and isOpen returns false', () => {
71+
it('should close popup when isVisible is false and isOpen returns true', () => {
7272
popupRef.isOpen = jest.fn(() => true)
7373
mapRef.popups.getPopups = jest.fn(() => [popupRef])
7474
render(

src/hooks/constructLayer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('constructLayer', () => {
108108
)
109109
expect(createLayer).toEqual({ layer: 'TileLayer', options: {}, id: 'TileLayerId' })
110110
})
111-
it('should return TileLayer props if type equal to TileLayer', () => {
111+
it('should return BubbleLayer props if type equal to BubbleLayer', () => {
112112
const createLayer = constructLayer(
113113
{
114114
id: 'BubbleLayerId',

0 commit comments

Comments
 (0)