Skip to content

Commit

Permalink
Fix(DH): Enhance test setup and imrove imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Dec 5, 2023
1 parent 2938155 commit efa9686
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import GeoJSON from 'ol/format/GeoJSON'
import { Geometry } from 'ol/geom'
import TileLayer from 'ol/layer/Tile'
import VectorLayer from 'ol/layer/Vector'
import { Map, Feature } from 'ol'
import Map from 'ol/Map'
import Feature from 'ol/Feature'
import OSM from 'ol/source/OSM'
import VectorSource from 'ol/source/Vector'
import { Fill, RegularShape, Stroke, Style } from 'ol/style'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
MapManagerService,
} from '@geonetwork-ui/feature/map'
import { FEATURE_COLLECTION_POINT_FIXTURE_4326 } from '@geonetwork-ui/common/fixtures'
import { Feature, Map } from 'ol'
import Map from 'ol/Map'
import Feature from 'ol/Feature'
import GeoJSON from 'ol/format/GeoJSON'
import TileLayer from 'ol/layer/Tile'
import VectorLayer from 'ol/layer/Vector'
Expand All @@ -23,13 +24,6 @@ import { Subject } from 'rxjs'
import { GeoTableViewComponent } from './geo-table-view.component'
import { Geometry } from 'ol/geom'

class ResizeObserverMock {
observe = jest.fn()
unobserve = jest.fn()
}

;(window as any).ResizeObserver = ResizeObserverMock

const vectorLayer = new VectorLayer({
source: new VectorSource({
features: new GeoJSON().readFeatures(
Expand Down
7 changes: 7 additions & 0 deletions libs/feature/dataviz/src/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ getTestBed().initTestEnvironment(
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
)

class ResizeObserverMock {
observe = jest.fn()
unobserve = jest.fn()
}

;(window as any).ResizeObserver = ResizeObserverMock
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ import {
} from './map-context.service'
import Feature from 'ol/Feature'

class ResizeObserverMock {
observe = jest.fn()
unobserve = jest.fn()
}

;(window as any).ResizeObserver = ResizeObserverMock

const mapStyleServiceMock = {
createDefaultStyle: jest.fn(() => new Style()),
styles: {
Expand Down
6 changes: 1 addition & 5 deletions libs/feature/map/src/lib/utils/map-utils-wms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export class MapUtilsWMSService {
)
}

async getProjFromEPSG(EPSGCode) {
return fromEPSGCode(EPSGCode)
}

async getLonLatBBox(wmsLayerFull: WmsLayerFull): Promise<Extent> {
const { boundingBoxes } = wmsLayerFull
const lonLatCRS = Object.keys(boundingBoxes)?.find((crs) =>
Expand All @@ -46,7 +42,7 @@ export class MapUtilsWMSService {
} else {
const availableEPSGCode = Object.keys(boundingBoxes)[0]
register(proj4)
const proj = await this.getProjFromEPSG(availableEPSGCode)
const proj = await fromEPSGCode(availableEPSGCode)
proj4.defs(availableEPSGCode, proj)

const bboxWithFiniteNumbers = [
Expand Down
6 changes: 0 additions & 6 deletions libs/feature/map/src/lib/utils/map-utils.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ jest.mock('ol/proj/proj4', () => {
register: registerMock,
}
})
class ResizeObserverMock {
observe = jest.fn()
unobserve = jest.fn()
}

;(window as any).ResizeObserver = ResizeObserverMock

const wmsUtilsMock = {
getLayerLonLatBBox: jest.fn(() => of([1.33, 48.81, 4.3, 51.1])),
Expand Down
7 changes: 7 additions & 0 deletions libs/feature/map/src/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ getTestBed().initTestEnvironment(
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
)

class ResizeObserverMock {
observe = jest.fn()
unobserve = jest.fn()
}

;(window as any).ResizeObserver = ResizeObserverMock

0 comments on commit efa9686

Please sign in to comment.