Refactoring of tests
This commit is contained in:
parent
555dbf3478
commit
f67d0701b0
19 changed files with 64 additions and 28 deletions
|
@ -49,7 +49,7 @@ export default class ActorsSpec extends T {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
super("Actors", [
|
super([
|
||||||
[
|
[
|
||||||
"download latest version",
|
"download latest version",
|
||||||
() => {
|
() => {
|
||||||
|
|
31
test/CreateNoteImportLayer.spec.ts
Normal file
31
test/CreateNoteImportLayer.spec.ts
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import T from "./TestHelper";
|
||||||
|
import CreateNoteImportLayer from "../Models/ThemeConfig/Conversion/CreateNoteImportLayer";
|
||||||
|
import * as bookcases from "../assets/layers/public_bookcase/public_bookcase.json"
|
||||||
|
import {DesugaringContext, PrepareLayer} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
|
||||||
|
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
|
||||||
|
import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson";
|
||||||
|
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
export default class CreateNoteImportLayerSpec extends T {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super([
|
||||||
|
["Bookcase", () => {
|
||||||
|
const desugaringState: DesugaringContext = {
|
||||||
|
sharedLayers: new Map<string, LayerConfigJson>(),
|
||||||
|
tagRenderings: new Map<string, TagRenderingConfigJson>()
|
||||||
|
|
||||||
|
}
|
||||||
|
const layerPrepare = new PrepareLayer()
|
||||||
|
const layer = new LayerConfig(layerPrepare.convertStrict(desugaringState, bookcases, "ImportLayerGeneratorTest:Parse bookcases"), "ImportLayerGeneratorTest: init bookcases-layer")
|
||||||
|
const generator = new CreateNoteImportLayer()
|
||||||
|
const generatedLayer = generator.convertStrict(desugaringState, layer, "ImportLayerGeneratorTest: convert")
|
||||||
|
fs.writeFileSync("bookcases-import-layer.generated.json", JSON.stringify(generatedLayer, null, " "), "utf8")
|
||||||
|
console.log(JSON.stringify(generatedLayer, null, " "))
|
||||||
|
}]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -89,8 +89,7 @@ export default class GeoOperationsSpec extends T {
|
||||||
private static outsidePolygon = [4.02099609375, 47.81315451752768]
|
private static outsidePolygon = [4.02099609375, 47.81315451752768]
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(
|
super([
|
||||||
"GeoOperationsSpec", [
|
|
||||||
["Point out of polygon", () => {
|
["Point out of polygon", () => {
|
||||||
GeoOperationsSpec.isFalse(GeoOperations.inside([
|
GeoOperationsSpec.isFalse(GeoOperations.inside([
|
||||||
3.779296875,
|
3.779296875,
|
||||||
|
|
|
@ -6,8 +6,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
||||||
|
|
||||||
export default class ImageAttributionSpec extends T {
|
export default class ImageAttributionSpec extends T {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(
|
super([
|
||||||
"imageattribution", [
|
|
||||||
[
|
[
|
||||||
"Should find all the images",
|
"Should find all the images",
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {Utils} from "../Utils";
|
||||||
export default class ImageProviderSpec extends T {
|
export default class ImageProviderSpec extends T {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("ImageProvider", [
|
super([
|
||||||
["Search images", () => {
|
["Search images", () => {
|
||||||
|
|
||||||
let i = 0
|
let i = 0
|
||||||
|
|
|
@ -141,9 +141,7 @@ export default class LegacyThemeLoaderSpec extends T {
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("LegacyThemeLoader",
|
super([
|
||||||
|
|
||||||
[
|
|
||||||
["Walking_node_theme", () => {
|
["Walking_node_theme", () => {
|
||||||
|
|
||||||
const config = LegacyThemeLoaderSpec.walking_node_theme
|
const config = LegacyThemeLoaderSpec.walking_node_theme
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default class OsmConnectionSpec extends T {
|
||||||
private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n"
|
private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n"
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("osmconnection", [
|
super([
|
||||||
["login on dev",
|
["login on dev",
|
||||||
() => {
|
() => {
|
||||||
const osmConn = new OsmConnection({
|
const osmConn = new OsmConnection({
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {OsmObject} from "../Logic/Osm/OsmObject";
|
||||||
|
|
||||||
export default class OsmObjectSpec extends T {
|
export default class OsmObjectSpec extends T {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("osmobject", [
|
super( [
|
||||||
[
|
[
|
||||||
"Download referencing ways",
|
"Download referencing ways",
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -548,7 +548,7 @@ export default class RelationSplitHandlerSpec extends T {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
super("relationsplithandler", [
|
super( [
|
||||||
["split 295132739",
|
["split 295132739",
|
||||||
async () => {
|
async () => {
|
||||||
// Lets mimick a split action of https://www.openstreetmap.org/way/295132739
|
// Lets mimick a split action of https://www.openstreetmap.org/way/295132739
|
||||||
|
|
|
@ -324,7 +324,7 @@ export default class ReplaceGeometrySpec extends T {
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("ReplaceGeometry", [
|
super( [
|
||||||
["House replacement with connected node", async () => {
|
["House replacement with connected node", async () => {
|
||||||
|
|
||||||
Minimap.createMiniMap = () => undefined;
|
Minimap.createMiniMap = () => undefined;
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default class SplitActionSpec extends T {
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("splitaction", [
|
super([
|
||||||
["split 295132739",
|
["split 295132739",
|
||||||
() => SplitActionSpec.split().then(_ => console.log("OK"))],
|
() => SplitActionSpec.split().then(_ => console.log("OK"))],
|
||||||
["split 295132739 on already existing node",
|
["split 295132739 on already existing node",
|
||||||
|
|
|
@ -13,7 +13,7 @@ import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig";
|
||||||
export default class TagSpec extends T {
|
export default class TagSpec extends T {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("tag", [
|
super( [
|
||||||
["Tag replacement works in translation", () => {
|
["Tag replacement works in translation", () => {
|
||||||
const tr = new Translation({
|
const tr = new Translation({
|
||||||
"en": "Test {key} abc"
|
"en": "Test {key} abc"
|
||||||
|
|
|
@ -15,12 +15,14 @@ import ImageProviderSpec from "./ImageProvider.spec";
|
||||||
import ActorsSpec from "./Actors.spec";
|
import ActorsSpec from "./Actors.spec";
|
||||||
import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
|
import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
|
||||||
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
|
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
|
||||||
|
import T from "./TestHelper";
|
||||||
|
import CreateNoteImportLayerSpec from "./CreateNoteImportLayer.spec";
|
||||||
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
||||||
ScriptUtils.fixUtils()
|
ScriptUtils.fixUtils()
|
||||||
const allTests = [
|
const allTests : T[] = [
|
||||||
new OsmObjectSpec(),
|
new OsmObjectSpec(),
|
||||||
new TagSpec(),
|
new TagSpec(),
|
||||||
new ImageAttributionSpec(),
|
new ImageAttributionSpec(),
|
||||||
|
@ -35,7 +37,8 @@ async function main() {
|
||||||
new ImageProviderSpec(),
|
new ImageProviderSpec(),
|
||||||
new ActorsSpec(),
|
new ActorsSpec(),
|
||||||
new ReplaceGeometrySpec(),
|
new ReplaceGeometrySpec(),
|
||||||
new LegacyThemeLoaderSpec()
|
new LegacyThemeLoaderSpec(),
|
||||||
|
new CreateNoteImportLayerSpec()
|
||||||
]
|
]
|
||||||
|
|
||||||
Utils.externalDownloadFunction = async (url) => {
|
Utils.externalDownloadFunction = async (url) => {
|
||||||
|
@ -54,12 +57,20 @@ async function main() {
|
||||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||||
let testsToRun = allTests
|
let testsToRun = allTests
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
args = args.map(a => a.toLowerCase())
|
args = args.map(a => a.toLowerCase()).map(a => {
|
||||||
|
if(!a.endsWith("spec")){
|
||||||
|
return a + "spec"
|
||||||
|
}else{
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
})
|
||||||
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testsToRun.length == 0) {
|
if (testsToRun.length == 0) {
|
||||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
const available = allTests.map(t => t.name)
|
||||||
|
available.sort()
|
||||||
|
throw "No tests found. Try one of " + available.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < testsToRun.length; i++) {
|
for (let i = 0; i < testsToRun.length; i++) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ export default class T {
|
||||||
public readonly name: string;
|
public readonly name: string;
|
||||||
private readonly _tests: [string, (() => (void | Promise<void>))][];
|
private readonly _tests: [string, (() => (void | Promise<void>))][];
|
||||||
|
|
||||||
constructor(testsuite: string, tests: [string, () => (Promise<void> | void)][]) {
|
constructor(tests: [string, () => (Promise<void> | void)][]) {
|
||||||
this.name = testsuite
|
this.name = this.constructor.name;
|
||||||
this._tests = tests;
|
this._tests = tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ import Constants from "../Models/Constants";
|
||||||
|
|
||||||
export default class ThemeSpec extends T {
|
export default class ThemeSpec extends T {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("theme",
|
super( [
|
||||||
[
|
|
||||||
["Nested overrides work", () => {
|
["Nested overrides work", () => {
|
||||||
|
|
||||||
let themeConfigJson: LayoutConfigJson = {
|
let themeConfigJson: LayoutConfigJson = {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {equal} from "assert";
|
||||||
export default class TileFreshnessCalculatorSpec extends T {
|
export default class TileFreshnessCalculatorSpec extends T {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("TileFreshnessCalculatorSpec", [
|
super( [
|
||||||
[
|
[
|
||||||
"TileFresnessTests",
|
"TileFresnessTests",
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {Denomination} from "../Models/Denomination";
|
||||||
export default class UnitsSpec extends T {
|
export default class UnitsSpec extends T {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("units", [
|
super( [
|
||||||
["Simple canonicalize", () => {
|
["Simple canonicalize", () => {
|
||||||
|
|
||||||
const unit = new Denomination({
|
const unit = new Denomination({
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default class UtilsSpec extends T {
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("utils", [
|
super( [
|
||||||
["Sort object keys", () => {
|
["Sort object keys", () => {
|
||||||
const o = {
|
const o = {
|
||||||
x: 'x',
|
x: 'x',
|
||||||
|
|
|
@ -7255,8 +7255,7 @@ export default class WikidataSpecTest extends T {
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Wikidata",
|
super( [
|
||||||
[
|
|
||||||
["Download Lion", async () => {
|
["Download Lion", async () => {
|
||||||
|
|
||||||
Utils.injectJsonDownloadForTests(
|
Utils.injectJsonDownloadForTests(
|
||||||
|
|
Loading…
Reference in a new issue