Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test env config mount to globalconfig #2195

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/GlobalConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* idle/worker etc
*/
const GlobalConfig = {
//test env
isTest: false,
//idle logging
idleLog: false,
//idle 时间阈值
Expand Down
4 changes: 2 additions & 2 deletions src/core/Eventable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Browser from './Browser';
import GlobalConfig from '../GlobalConfig';
import { extend, isString, isNil, UID, isNumber } from './util';
import { stopPropagation } from './util/dom';
/**
Expand Down Expand Up @@ -69,7 +69,7 @@ const Eventable = Base =>
if (l > 0) {
for (let i = 0; i < l; i++) {
if (handler === handlerChain[i].handler && handlerChain[i].context === context) {
if (!Browser.isTest) {
if (!GlobalConfig.isTest) {
console.warn(this, `find '${eventsOn}' handler:`, handler, ' The old listener function will be removed');
}
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/GeometryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Coordinate from '../geo/Coordinate';
import PointExtent from '../geo/PointExtent';
import Extent from '../geo/Extent';
import Geometry from './Geometry';
import Browser from '../core/Browser';
import GlobalConfig from '../GlobalConfig';

const TEMP_EXTENT = new PointExtent();

Expand Down Expand Up @@ -290,7 +290,7 @@ class GeometryCollection extends Geometry {
continue;
}
if (isSelf(geometry)) {
if (!Browser.isTest) {
if (!GlobalConfig.isTest) {
console.error(geometry, ' is GeometryCollection sub class,it Cannot be placed in GeometryCollection');
}
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/map/Map.DomEvents.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Browser from '../core/Browser';
import GlobalConfig from '../GlobalConfig';
import { now, extend } from '../core/util';
import {
addDomEvent,
Expand Down Expand Up @@ -223,7 +223,7 @@ Map.include(/** @lends Map.prototype */ {
}
const clickTimeThreshold = this.options['clickTimeThreshold'];
const type = e.type;
if (isMoveEvent(type) && !Browser.isTest && isMousemoveEventBlocked(this, this.options['mousemoveThrottleTime'])) {
if (isMoveEvent(type) && !GlobalConfig.isTest && isMousemoveEventBlocked(this, this.options['mousemoveThrottleTime'])) {
return;
}
const isMouseDown = type === 'mousedown' || (type === 'touchstart' && (!e.touches || e.touches.length === 1));
Expand Down
4 changes: 2 additions & 2 deletions src/map/handler/Map.GeometryEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { on, off, getEventContainerPoint, preventDefault, stopPropagation, isMov
import Handler from '../../handler/Handler';
import Geometry from '../../geometry/Geometry';
import Map from '../Map';
import Browser from '../../core/Browser';
import GlobalConfig from '../../GlobalConfig';

const EVENTS =
/**
Expand Down Expand Up @@ -205,7 +205,7 @@ class MapGeometryEventsHandler extends Handler {
}
let oneMoreEvent = null;
const eventType = type || domEvent.type;
if (isMoveEvent(eventType) && !Browser.isTest && isMousemoveEventBlocked(this, map.options['mousemoveThrottleTime'])) {
if (isMoveEvent(eventType) && !GlobalConfig.isTest && isMousemoveEventBlocked(this, map.options['mousemoveThrottleTime'])) {
stopPropagation(domEvent);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/SpecCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function COMMON_CREATE_MAP(center, baseLayer, options) {
if (baseLayer) {
option.baseLayer = baseLayer;
}
maptalks.Browser.isTest = true;
maptalks.Globalconfig.isTest = true;
var map = new maptalks.Map(container, option);
return {
'container': container,
Expand Down