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",
|
||||
() => {
|
||||
|
|
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]
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
"GeoOperationsSpec", [
|
||||
super([
|
||||
["Point out of polygon", () => {
|
||||
GeoOperationsSpec.isFalse(GeoOperations.inside([
|
||||
3.779296875,
|
||||
|
|
|
@ -6,8 +6,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
|||
|
||||
export default class ImageAttributionSpec extends T {
|
||||
constructor() {
|
||||
super(
|
||||
"imageattribution", [
|
||||
super([
|
||||
[
|
||||
"Should find all the images",
|
||||
() => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {Utils} from "../Utils";
|
|||
export default class ImageProviderSpec extends T {
|
||||
|
||||
constructor() {
|
||||
super("ImageProvider", [
|
||||
super([
|
||||
["Search images", () => {
|
||||
|
||||
let i = 0
|
||||
|
|
|
@ -141,9 +141,7 @@ export default class LegacyThemeLoaderSpec extends T {
|
|||
}
|
||||
|
||||
constructor() {
|
||||
super("LegacyThemeLoader",
|
||||
|
||||
[
|
||||
super([
|
||||
["Walking_node_theme", () => {
|
||||
|
||||
const config = LegacyThemeLoaderSpec.walking_node_theme
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class OsmConnectionSpec extends T {
|
|||
private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n"
|
||||
|
||||
constructor() {
|
||||
super("osmconnection", [
|
||||
super([
|
||||
["login on dev",
|
||||
() => {
|
||||
const osmConn = new OsmConnection({
|
||||
|
|
|
@ -3,7 +3,7 @@ import {OsmObject} from "../Logic/Osm/OsmObject";
|
|||
|
||||
export default class OsmObjectSpec extends T {
|
||||
constructor() {
|
||||
super("osmobject", [
|
||||
super( [
|
||||
[
|
||||
"Download referencing ways",
|
||||
() => {
|
||||
|
|
|
@ -548,7 +548,7 @@ export default class RelationSplitHandlerSpec extends T {
|
|||
)
|
||||
|
||||
|
||||
super("relationsplithandler", [
|
||||
super( [
|
||||
["split 295132739",
|
||||
async () => {
|
||||
// Lets mimick a split action of https://www.openstreetmap.org/way/295132739
|
||||
|
|
|
@ -324,7 +324,7 @@ export default class ReplaceGeometrySpec extends T {
|
|||
|
||||
|
||||
constructor() {
|
||||
super("ReplaceGeometry", [
|
||||
super( [
|
||||
["House replacement with connected node", async () => {
|
||||
|
||||
Minimap.createMiniMap = () => undefined;
|
||||
|
|
|
@ -8,7 +8,7 @@ export default class SplitActionSpec extends T {
|
|||
|
||||
|
||||
constructor() {
|
||||
super("splitaction", [
|
||||
super([
|
||||
["split 295132739",
|
||||
() => SplitActionSpec.split().then(_ => console.log("OK"))],
|
||||
["split 295132739 on already existing node",
|
||||
|
|
|
@ -13,7 +13,7 @@ import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig";
|
|||
export default class TagSpec extends T {
|
||||
|
||||
constructor() {
|
||||
super("tag", [
|
||||
super( [
|
||||
["Tag replacement works in translation", () => {
|
||||
const tr = new Translation({
|
||||
"en": "Test {key} abc"
|
||||
|
|
|
@ -15,12 +15,14 @@ import ImageProviderSpec from "./ImageProvider.spec";
|
|||
import ActorsSpec from "./Actors.spec";
|
||||
import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
|
||||
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
|
||||
import T from "./TestHelper";
|
||||
import CreateNoteImportLayerSpec from "./CreateNoteImportLayer.spec";
|
||||
|
||||
|
||||
async function main() {
|
||||
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
const allTests : T[] = [
|
||||
new OsmObjectSpec(),
|
||||
new TagSpec(),
|
||||
new ImageAttributionSpec(),
|
||||
|
@ -35,7 +37,8 @@ async function main() {
|
|||
new ImageProviderSpec(),
|
||||
new ActorsSpec(),
|
||||
new ReplaceGeometrySpec(),
|
||||
new LegacyThemeLoaderSpec()
|
||||
new LegacyThemeLoaderSpec(),
|
||||
new CreateNoteImportLayerSpec()
|
||||
]
|
||||
|
||||
Utils.externalDownloadFunction = async (url) => {
|
||||
|
@ -54,12 +57,20 @@ async function main() {
|
|||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
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)
|
||||
}
|
||||
|
||||
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++) {
|
||||
|
|
|
@ -3,8 +3,8 @@ export default class T {
|
|||
public readonly name: string;
|
||||
private readonly _tests: [string, (() => (void | Promise<void>))][];
|
||||
|
||||
constructor(testsuite: string, tests: [string, () => (Promise<void> | void)][]) {
|
||||
this.name = testsuite
|
||||
constructor(tests: [string, () => (Promise<void> | void)][]) {
|
||||
this.name = this.constructor.name;
|
||||
this._tests = tests;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ import Constants from "../Models/Constants";
|
|||
|
||||
export default class ThemeSpec extends T {
|
||||
constructor() {
|
||||
super("theme",
|
||||
[
|
||||
super( [
|
||||
["Nested overrides work", () => {
|
||||
|
||||
let themeConfigJson: LayoutConfigJson = {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {equal} from "assert";
|
|||
export default class TileFreshnessCalculatorSpec extends T {
|
||||
|
||||
constructor() {
|
||||
super("TileFreshnessCalculatorSpec", [
|
||||
super( [
|
||||
[
|
||||
"TileFresnessTests",
|
||||
() => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {Denomination} from "../Models/Denomination";
|
|||
export default class UnitsSpec extends T {
|
||||
|
||||
constructor() {
|
||||
super("units", [
|
||||
super( [
|
||||
["Simple canonicalize", () => {
|
||||
|
||||
const unit = new Denomination({
|
||||
|
|
|
@ -39,7 +39,7 @@ export default class UtilsSpec extends T {
|
|||
}
|
||||
|
||||
constructor() {
|
||||
super("utils", [
|
||||
super( [
|
||||
["Sort object keys", () => {
|
||||
const o = {
|
||||
x: 'x',
|
||||
|
|
|
@ -7255,8 +7255,7 @@ export default class WikidataSpecTest extends T {
|
|||
}
|
||||
|
||||
constructor() {
|
||||
super("Wikidata",
|
||||
[
|
||||
super( [
|
||||
["Download Lion", async () => {
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
|
|
Loading…
Reference in a new issue