Merge pull request #13905 from MoonE/replace-enums

Replace enums with typedefs
This commit is contained in:
MoonE
2022-07-30 18:12:34 +02:00
committed by GitHub
24 changed files with 83 additions and 177 deletions

View File

@@ -1,14 +1,15 @@
import Event from '../../../../../src/ol/events/Event.js';
import Map from '../../../../../src/ol/Map.js';
import MapBrowserEvent from '../../../../../src/ol/MapBrowserEvent.js';
import MouseWheelZoom, {
Mode,
} from '../../../../../src/ol/interaction/MouseWheelZoom.js';
import MouseWheelZoom from '../../../../../src/ol/interaction/MouseWheelZoom.js';
import View from '../../../../../src/ol/View.js';
import {DEVICE_PIXEL_RATIO, FIREFOX} from '../../../../../src/ol/has.js';
describe('ol.interaction.MouseWheelZoom', function () {
let map, interaction;
/** @type {Map} */
let map;
/** @type {MouseWheelZoom} */
let interaction;
beforeEach(function () {
interaction = new MouseWheelZoom();
@@ -65,7 +66,7 @@ describe('ol.interaction.MouseWheelZoom', function () {
if (FIREFOX) {
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function (done) {
map.once('postrender', function () {
expect(interaction.mode_).to.be(Mode.TRACKPAD);
expect(interaction.mode_).to.be('trackpad');
done();
});
const event = new MapBrowserEvent('wheel', map, {
@@ -83,7 +84,7 @@ describe('ol.interaction.MouseWheelZoom', function () {
if (!FIREFOX) {
it('works in DOM_DELTA_PIXEL mode (trackpad)', function (done) {
map.once('postrender', function () {
expect(interaction.mode_).to.be(Mode.TRACKPAD);
expect(interaction.mode_).to.be('trackpad');
done();
});
const event = new MapBrowserEvent('wheel', map, {

View File

@@ -11,7 +11,6 @@ import TileState from '../../../../../../src/ol/TileState.js';
import VectorRenderTile from '../../../../../../src/ol/VectorRenderTile.js';
import VectorTile from '../../../../../../src/ol/VectorTile.js';
import VectorTileLayer from '../../../../../../src/ol/layer/VectorTile.js';
import VectorTileRenderType from '../../../../../../src/ol/layer/VectorTileRenderType.js';
import VectorTileSource from '../../../../../../src/ol/source/VectorTile.js';
import View from '../../../../../../src/ol/View.js';
import XYZ from '../../../../../../src/ol/source/XYZ.js';
@@ -124,7 +123,7 @@ describe('ol/renderer/canvas/VectorTileLayer', function () {
it('does not render images for pure vector rendering', function () {
const testLayer = new VectorTileLayer({
renderMode: VectorTileRenderType.VECTOR,
renderMode: 'vector',
source: source,
style: layerStyle,
});

View File

@@ -1,5 +1,4 @@
import Projection from '../../../src/ol/proj/Projection.js';
import Units from '../../../src/ol/proj/Units.js';
import View from '../../../src/ol/View.js';
import expect from '../expect.js';
import proj4 from 'proj4';
@@ -159,13 +158,13 @@ describe('ol/proj.js', function () {
describe('fromUserResolution()', function () {
it("adjusts a resolution for the user projection's units", function () {
useGeographic();
const user = 1 / METERS_PER_UNIT['degrees'];
const user = 1 / METERS_PER_UNIT.degrees;
const resolution = fromUserResolution(user, 'EPSG:3857');
expect(resolution).to.roughlyEqual(1, 1e-9);
});
it('returns the original if no user projection is set', function () {
const user = METERS_PER_UNIT['meters'];
const user = METERS_PER_UNIT.meters;
const resolution = fromUserResolution(user, 'EPSG:3857');
expect(resolution).to.eql(user);
});
@@ -176,11 +175,11 @@ describe('ol/proj.js', function () {
useGeographic();
const dest = 1;
const resolution = toUserResolution(dest, 'EPSG:3857');
expect(resolution).to.eql(1 / METERS_PER_UNIT['degrees']);
expect(resolution).to.eql(1 / METERS_PER_UNIT.degrees);
});
it('returns the original if no user projection is set', function () {
const dest = METERS_PER_UNIT['degrees'];
const dest = METERS_PER_UNIT.degrees;
const resolution = toUserResolution(dest, 'EPSG:3857');
expect(resolution).to.eql(dest);
});
@@ -435,7 +434,7 @@ describe('ol/proj.js', function () {
it('returns the correct point resolution for EPSG:3857 with custom units', function () {
let pointResolution = getPointResolution(
'EPSG:3857',
METERS_PER_UNIT['degrees'],
METERS_PER_UNIT.degrees,
[0, 0],
'degrees'
);
@@ -506,7 +505,7 @@ describe('ol/proj.js', function () {
const proj = getProjection('EPSG:4258');
expect(proj.getCode()).to.eql('EPSG:4258');
expect(proj.getUnits()).to.eql('degrees');
expect(proj.getMetersPerUnit()).to.eql(METERS_PER_UNIT[Units.DEGREES]);
expect(proj.getMetersPerUnit()).to.eql(METERS_PER_UNIT.degrees);
delete proj4.defs['EPSG:4258'];
});

View File

@@ -444,7 +444,7 @@ describe('ol/tilegrid/TileGrid.js', function () {
const grid = createForProjection(projection);
const resolutions = grid.getResolutions();
expect(resolutions[5]).to.be(
(360 * METERS_PER_UNIT['degrees']) / DEFAULT_TILE_SIZE / Math.pow(2, 5)
(360 * METERS_PER_UNIT.degrees) / DEFAULT_TILE_SIZE / Math.pow(2, 5)
);
});

View File

@@ -1,7 +1,6 @@
import MVT from '../../../../src/ol/format/MVT.js';
import Map from '../../../../src/ol/Map.js';
import VectorTileLayer from '../../../../src/ol/layer/VectorTile.js';
import VectorTileRenderType from '../../../../src/ol/layer/VectorTileRenderType.js';
import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
import View from '../../../../src/ol/View.js';
import {createXYZ} from '../../../../src/ol/tilegrid.js';
@@ -9,7 +8,7 @@ import {createXYZ} from '../../../../src/ol/tilegrid.js';
new Map({
layers: [
new VectorTileLayer({
renderMode: VectorTileRenderType.VECTOR,
renderMode: 'vector',
opacity: 0.1,
source: new VectorTileSource({
format: new MVT(),

View File

@@ -1,7 +1,6 @@
import MVT from '../../../../src/ol/format/MVT.js';
import Map from '../../../../src/ol/Map.js';
import VectorTileLayer from '../../../../src/ol/layer/VectorTile.js';
import VectorTileRenderType from '../../../../src/ol/layer/VectorTileRenderType.js';
import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
import View from '../../../../src/ol/View.js';
import {createXYZ} from '../../../../src/ol/tilegrid.js';
@@ -9,7 +8,7 @@ import {createXYZ} from '../../../../src/ol/tilegrid.js';
new Map({
layers: [
new VectorTileLayer({
renderMode: VectorTileRenderType.VECTOR,
renderMode: 'vector',
source: new VectorTileSource({
format: new MVT(),
tileGrid: createXYZ(),