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

Use Node's built-in test runner for tests that don't need to be run in a browser #1306

Merged
merged 55 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1c83afa
Start the process of splitting up our tests into 'browser' and 'unit'
bhousel Jan 12, 2024
721e938
Use full file path with extension with import/export
bhousel Jan 16, 2024
329f605
Start moving over the actions from browser tests to node tests
bhousel Jan 17, 2024
1ae6401
Update change_member and change_preset tests
bhousel Jan 17, 2024
207baee
Update change_tags and circularize tests
bhousel Jan 18, 2024
9864573
Nest `.disabled()` tests in a disabled section
bhousel Jan 18, 2024
f199fc1
Update connect tests
bhousel Jan 18, 2024
7be5b66
Update all the various delete action tests
bhousel Jan 18, 2024
60a1629
Update discard_tags tests
bhousel Jan 22, 2024
a4b1be9
Update disconnect tests
bhousel Jan 22, 2024
0904523
Remove the todos
bhousel Jan 22, 2024
7342848
converted restrict_turn through upgrade_tags test to node.js
tannerwuster Jan 22, 2024
4d253db
converted reflect.test.js
tannerwuster Jan 22, 2024
7779d57
Update disconnect tests
bhousel Jan 22, 2024
de310fa
converted noop.test.js
tannerwuster Jan 22, 2024
3e6355e
Update join tests
bhousel Jan 23, 2024
7b8e797
Update merge, merge_node tests
bhousel Jan 23, 2024
3d44507
Update merge_polygon tests
bhousel Jan 23, 2024
38967b0
Replace async/await with describe/it
bhousel Jan 24, 2024
8c64b05
Update merge_remote_changes tests
bhousel Jan 24, 2024
b7e7bf4
Move osm and geo tests from `browser/` to `unit/`
bhousel Jan 24, 2024
7eb4cfb
Update the geo tests (needed to add geo to headless.js too)
bhousel Jan 24, 2024
b57411b
Update osmChangeset and osmEntity tests
bhousel Jan 24, 2024
882314b
updated upgrade_tags
tannerwuster Jan 24, 2024
268c446
unrestrict_turn
tannerwuster Jan 24, 2024
407faaf
straighten_way updated
tannerwuster Jan 24, 2024
83d0fe6
straighten_nodes updated
tannerwuster Jan 24, 2024
e069a59
revert updated
tannerwuster Jan 25, 2024
9bc436c
reverse updated
tannerwuster Jan 25, 2024
554b7ae
restrict_turn updated
tannerwuster Jan 25, 2024
7701298
reverse test updated to use const
tannerwuster Jan 25, 2024
404983a
revert test updated to use const
tannerwuster Jan 25, 2024
6663627
split test updated to use const
tannerwuster Jan 25, 2024
c971924
straighten tests updated to use const
tannerwuster Jan 25, 2024
6147bed
unrestrict test updated to use const
tannerwuster Jan 25, 2024
81c89ec
reflect updated to not use async
tannerwuster Jan 25, 2024
12bf1a5
noop updated to not use async
tannerwuster Jan 25, 2024
561697f
move updated
tannerwuster Jan 25, 2024
48a472b
move_node updated
tannerwuster Jan 25, 2024
22a3c00
orthogonalize updated
tannerwuster Jan 25, 2024
40a90ca
Update osm intersection and turn tests
bhousel Jan 25, 2024
92615f2
way test updated
tannerwuster Jan 25, 2024
93cfa2b
tags test updated
tannerwuster Jan 25, 2024
d654469
Update osm lanes tests
bhousel Jan 26, 2024
4f88d85
relation test updated
tannerwuster Jan 26, 2024
b7f58cd
relation test updated with arrow notation
tannerwuster Jan 26, 2024
7495306
note test updated
tannerwuster Jan 26, 2024
81b4917
pacify eslint
bhousel Jan 26, 2024
f15de4f
Update osm multipolygon tests
bhousel Jan 26, 2024
b334e3a
Move over the `lib` tests from `browser` to `unit`, update Category a…
bhousel Jan 26, 2024
cdb4c6f
Update Difference, Graph, ImagerySource tests
bhousel Jan 26, 2024
e405f4c
Update tests for Preset and Tree
bhousel Jan 29, 2024
60534c1
node test updated
tannerwuster Jan 29, 2024
5ffddd2
node test updated with arrow notation
tannerwuster Jan 29, 2024
edb5e07
pacify eslint
bhousel Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

14 changes: 7 additions & 7 deletions karma.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ module.exports = function (config) {
{ pattern: 'dist/rapid.js', included: true },
{ pattern: 'dist/rapid.css', included: true },
{ pattern: 'dist/**/*', included: false },
{ pattern: 'test/spec/renderer/*.json', included: true, served: true},
'test/spec/spec_helpers.js',
'test/spec/**/*.js'
{ pattern: 'test/browser/renderer/*.json', included: true, served: true},
'test/browser/spec_helpers.js',
'test/browser/**/*.js'
],

// list of files / patterns to exclude
exclude: [
'test/spec/pixi/*.js',
'test/browser/pixi/*.js',
// Comment the next line to run the OSM renderer-specific unit test, which right now merely exercise the code.
// These tests don't actually make any assertions and therefore always succeed.
'test/spec/renderer/PixiRenderer.js'
'test/browser/renderer/PixiRenderer.js'
],

proxies: {
Expand All @@ -48,7 +48,7 @@ module.exports = function (config) {
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
preprocessors: {
'dist/rapid.js': ['coverage'],
'test/spec/renderer/*.json': ['json_fixtures']
'test/browser/renderer/*.json': ['json_fixtures']
},

// test results reporter to use
Expand Down Expand Up @@ -98,4 +98,4 @@ module.exports = function (config) {
}
}
});
};
};
10 changes: 5 additions & 5 deletions modules/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { select as d3_select } from 'd3-selection';
import { Projection, geoScaleToZoom } from '@rapid-sdk/math';
import { utilUnicodeCharsTruncated } from '@rapid-sdk/util';

import { behaviors } from './behaviors';
import { modes } from './modes';
import { services } from './services';
import { systems } from './core';
import { behaviors } from './behaviors/index.js';
import { modes } from './modes/index.js';
import { services } from './services/index.js';
import { systems } from './core/index.js';

import { utilKeybinding } from './util';
import { utilKeybinding } from './util/keybinding.js';

const MINZOOM = 15;
const TILESIZE = 256;
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/add_member.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { utilArrayGroupBy, utilObjectOmit } from '@rapid-sdk/util';

import { osmJoinWays } from '../osm/multipolygon';
import { osmWay } from '../osm/way';
import { osmJoinWays } from '../osm/multipolygon.js';
import { osmWay } from '../osm/way.js';


export function actionAddMember(relationId, member, memberIndex, insertPair) {
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/change_preset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionSyncCrossingTags } from './sync_crossing_tags';
import { actionSyncCrossingTags } from './sync_crossing_tags.js';

export function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
return function action(graph) {
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/circularize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { vecInterp, vecLength, vecLengthSquare } from '@rapid-sdk/math';
import { utilArrayUniq } from '@rapid-sdk/util';

import { osmNode } from '../osm/node';
import { osmNode } from '../osm/node.js';


export function actionCircularize(wayId, projection, maxAngle) {
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/connect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { utilArrayUniq } from '@rapid-sdk/util';

import { actionDeleteNode } from './delete_node';
import { actionDeleteWay } from './delete_way';
import { actionDeleteNode } from './delete_node.js';
import { actionDeleteWay } from './delete_way.js';


// Connect the ways at the given nodes.
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/delete_member.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionDeleteRelation } from './delete_relation';
import { actionDeleteRelation } from './delete_relation.js';


export function actionDeleteMember(relationId, memberIndex) {
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/delete_members.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionDeleteMember } from './delete_member';
import { actionDeleteMember } from './delete_member.js';


export function actionDeleteMembers(relationId, memberIndexes) {
Expand Down
6 changes: 3 additions & 3 deletions modules/actions/delete_multiple.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { actionDeleteNode } from './delete_node';
import { actionDeleteRelation } from './delete_relation';
import { actionDeleteWay } from './delete_way';
import { actionDeleteNode } from './delete_node.js';
import { actionDeleteRelation } from './delete_relation.js';
import { actionDeleteWay } from './delete_way.js';


export function actionDeleteMultiple(ids) {
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/delete_node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actionDeleteRelation } from './delete_relation';
import { actionDeleteWay } from './delete_way';
import { actionDeleteRelation } from './delete_relation.js';
import { actionDeleteWay } from './delete_way.js';


// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteNodeAction.as
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/delete_relation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { utilArrayUniq } from '@rapid-sdk/util';

import { actionDeleteMultiple } from './delete_multiple';
import { actionDeleteMultiple } from './delete_multiple.js';


// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/delete_way.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { osmNodeGeometriesForTags } from '../osm/tags';
import { actionDeleteRelation } from './delete_relation';
import { osmNodeGeometriesForTags } from '../osm/tags.js';
import { actionDeleteRelation } from './delete_relation.js';


// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
Expand Down
20 changes: 10 additions & 10 deletions modules/actions/disconnect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { osmNode } from '../osm/node';
import { osmNode } from '../osm/node.js';


// Disconnect the ways at the given node.
Expand All @@ -15,7 +15,7 @@ import { osmNode } from '../osm/node';
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/UnGlueAction.java
//
export function actionDisconnect(nodeId, newNodeID) {
var wayIds;
var _wayIDs;


var action = function(graph) {
Expand Down Expand Up @@ -50,7 +50,7 @@ export function actionDisconnect(nodeId, newNodeID) {
var way, waynode;
for (var i = 0; i < parentWays.length; i++) {
way = parentWays[i];
if (wayIds && wayIds.indexOf(way.id) === -1) {
if (_wayIDs && _wayIDs.indexOf(way.id) === -1) {
keeping = true;
continue;
}
Expand All @@ -62,8 +62,8 @@ export function actionDisconnect(nodeId, newNodeID) {
if (waynode === nodeId) {
if (way.isClosed() &&
parentWays.length > 1 &&
wayIds &&
wayIds.indexOf(way.id) !== -1 &&
_wayIDs &&
_wayIDs.indexOf(way.id) !== -1 &&
j === way.nodes.length - 1) {
continue;
}
Expand Down Expand Up @@ -103,9 +103,9 @@ export function actionDisconnect(nodeId, newNodeID) {
var relations = graph.parentRelations(way);
relations.forEach(function(relation) {
if (relation.id in seenRelationIds) {
if (wayIds) {
if (wayIds.indexOf(way.id) !== -1 ||
wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
if (_wayIDs) {
if (_wayIDs.indexOf(way.id) !== -1 ||
_wayIDs.indexOf(seenRelationIds[relation.id]) !== -1) {
sharedRelation = relation;
}
} else {
Expand All @@ -122,8 +122,8 @@ export function actionDisconnect(nodeId, newNodeID) {


action.limitWays = function(val) {
if (!arguments.length) return wayIds;
wayIds = val;
if (!arguments.length) return _wayIDs;
_wayIDs = val;
return action;
};

Expand Down
3 changes: 2 additions & 1 deletion modules/actions/extract.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { polygonCentroid as d3_polygonCentroid } from 'd3-polygon';
import { vecInterp } from '@rapid-sdk/math';
import { osmNode } from '../osm/node';

import { osmNode } from '../osm/node.js';


export function actionExtract(entityID, projection) {
Expand Down
81 changes: 40 additions & 41 deletions modules/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
export { actionAddEntity } from './add_entity';
export { actionAddMember } from './add_member';
export { actionAddMidpoint } from './add_midpoint';
export { actionAddVertex } from './add_vertex';
export { actionChangeMember } from './change_member';
export { actionChangePreset } from './change_preset';
export { actionChangeTags } from './change_tags';
export { actionCircularize } from './circularize';
export { actionConnect } from './connect';
export { actionCopyEntities } from './copy_entities';
export { actionDeleteMember } from './delete_member';
export { actionDeleteMultiple } from './delete_multiple';
export { actionDeleteNode } from './delete_node';
export { actionDeleteRelation } from './delete_relation';
export { actionDeleteWay } from './delete_way';
export { actionDiscardTags } from './discard_tags';
export { actionDisconnect } from './disconnect';
export { actionExtract } from './extract';
export { actionJoin } from './join';
export { actionMerge } from './merge';
export { actionMergeNodes } from './merge_nodes';
export { actionMergePolygon } from './merge_polygon';
export { actionMergeRemoteChanges } from './merge_remote_changes';
export { actionMove } from './move';
export { actionMoveMember } from './move_member';
export { actionMoveNode } from './move_node';
export { actionNoop } from './noop';
export { actionOrthogonalize } from './orthogonalize';
export { actionRestrictTurn } from './restrict_turn';
export { actionReverse } from './reverse';
export { actionRevert } from './revert';
export { actionRotate } from './rotate';
export { actionScale } from './scale';
export { actionSplit } from './split';
export { actionStraightenNodes } from './straighten_nodes';
export { actionStraightenWay } from './straighten_way';
export { actionSyncCrossingTags } from './sync_crossing_tags';
export { actionUnrestrictTurn } from './unrestrict_turn';
export { actionAddEntity } from './add_entity.js';
export { actionAddMember } from './add_member.js';
export { actionAddMidpoint } from './add_midpoint.js';
export { actionAddVertex } from './add_vertex.js';
export { actionChangeMember } from './change_member.js';
export { actionChangePreset } from './change_preset.js';
export { actionChangeTags } from './change_tags.js';
export { actionCircularize } from './circularize.js';
export { actionConnect } from './connect.js';
export { actionCopyEntities } from './copy_entities.js';
export { actionDeleteMember } from './delete_member.js';
export { actionDeleteMultiple } from './delete_multiple.js';
export { actionDeleteNode } from './delete_node.js';
export { actionDeleteRelation } from './delete_relation.js';
export { actionDeleteWay } from './delete_way.js';
export { actionDiscardTags } from './discard_tags.js';
export { actionDisconnect } from './disconnect.js';
export { actionExtract } from './extract.js';
export { actionJoin } from './join.js';
export { actionMerge } from './merge.js';
export { actionMergeNodes } from './merge_nodes.js';
export { actionMergePolygon } from './merge_polygon.js';
export { actionMergeRemoteChanges } from './merge_remote_changes.js';
export { actionMove } from './move.js';
export { actionMoveMember } from './move_member.js';
export { actionMoveNode } from './move_node.js';
export { actionNoop } from './noop.js';
export { actionOrthogonalize } from './orthogonalize.js';
export { actionRapidAcceptFeature } from './rapid_accept_feature.js';
export { actionRestrictTurn } from './restrict_turn.js';
export { actionReverse } from './reverse.js';
export { actionRevert } from './revert.js';
export { actionRotate } from './rotate.js';
export { actionScale } from './scale.js';
export { actionSplit } from './split.js';
export { actionStraightenNodes } from './straighten_nodes.js';
export { actionStraightenWay } from './straighten_way.js';
export { actionSyncCrossingTags } from './sync_crossing_tags.js';
export { actionUnrestrictTurn } from './unrestrict_turn.js';
export { actionReflect } from './reflect.js';
export { actionUpgradeTags } from './upgrade_tags';

export { actionRapidAcceptFeature } from './rapid_accept_feature';
export { actionUpgradeTags } from './upgrade_tags.js';
8 changes: 4 additions & 4 deletions modules/actions/join.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { geomPathIntersections } from '@rapid-sdk/math';
import { utilArrayGroupBy, utilArrayIdentical, utilArrayIntersection } from '@rapid-sdk/util';

import { actionDeleteRelation } from './delete_relation';
import { actionDeleteWay } from './delete_way';
import { osmIsInterestingTag } from '../osm/tags';
import { osmJoinWays } from '../osm/multipolygon';
import { actionDeleteRelation } from './delete_relation.js';
import { actionDeleteWay } from './delete_way.js';
import { osmIsInterestingTag } from '../osm/tags.js';
import { osmJoinWays } from '../osm/multipolygon.js';


// Join ways at the end node they share.
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/merge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { utilArrayGroupBy, utilArrayUniq } from '@rapid-sdk/util';

import { osmTagSuggestingArea } from '../osm/tags';
import { osmTagSuggestingArea } from '../osm/tags.js';


export function actionMerge(ids) {
Expand Down
3 changes: 2 additions & 1 deletion modules/actions/merge_nodes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { actionConnect } from './connect';
import { vecAdd, vecScale } from '@rapid-sdk/math';

import { actionConnect } from './connect.js';


// `actionMergeNodes` is just a combination of:
//
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/merge_polygon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { geomPolygonContainsPolygon } from '@rapid-sdk/math';
import { utilArrayGroupBy, utilArrayIntersection, utilObjectOmit } from '@rapid-sdk/util';

import { osmJoinWays, osmRelation } from '../osm';
import { osmJoinWays, osmRelation } from '../osm/index.js';


export function actionMergePolygon(ids, newRelationId) {
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/merge_remote_changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { utilArrayUnion, utilArrayUniq } from '@rapid-sdk/util';
import deepEqual from 'fast-deep-equal';
import { diff3Merge } from 'node-diff3';

import { actionDeleteMultiple } from './delete_multiple';
import { osmEntity } from '../osm';
import { actionDeleteMultiple } from './delete_multiple.js';
import { osmEntity } from '../osm/entity.js';


export function actionMergeRemoteChanges(id, options = {}) {
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/move.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { geomPathIntersections, geomPathLength, vecAdd, vecAngle, vecEqual, vecInterp, vecSubtract } from '@rapid-sdk/math';
import { utilArrayIntersection } from '@rapid-sdk/util';

import { geoChooseEdge } from '../geo';
import { osmNode } from '../osm/node';
import { geoChooseEdge } from '../geo/index.js';
import { osmNode } from '../osm/node.js';


// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/MoveCommand.java
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/orthogonalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
vecAdd, vecEqual, vecInterp, vecLength, vecNormalize, vecProject, vecScale, vecSubtract
} from '@rapid-sdk/math';

import { actionDeleteNode } from './delete_node';
import { geoOrthoNormalizedDotProduct, geoOrthoCalcScore, geoOrthoCanOrthogonalize } from '../geo';
import { actionDeleteNode } from './delete_node.js';
import { geoOrthoNormalizedDotProduct, geoOrthoCalcScore, geoOrthoCanOrthogonalize } from '../geo/index.js';


export function actionOrthogonalize(wayID, projection, vertexID, degThresh, ep) {
Expand Down
3 changes: 2 additions & 1 deletion modules/actions/rapid_accept_feature.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { vecInterp } from '@rapid-sdk/math';
import { osmNode, osmRelation, osmWay } from '../osm';

import { osmNode, osmRelation, osmWay } from '../osm/index.js';


function findConnectionPoint(graph, newNode, targetWay, nodeA, nodeB) {
Expand Down
2 changes: 1 addition & 1 deletion modules/actions/restrict_turn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { osmRelation } from '../osm/relation';
import { osmRelation } from '../osm/relation.js';


// `actionRestrictTurn` creates a turn restriction relation.
Expand Down
4 changes: 2 additions & 2 deletions modules/actions/revert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actionDeleteRelation } from './delete_relation';
import { actionDeleteWay } from './delete_way';
import { actionDeleteRelation } from './delete_relation.js';
import { actionDeleteWay } from './delete_way.js';


export function actionRevert(id) {
Expand Down
Loading