Fix tests

This commit is contained in:
pietervdvn 2022-07-06 14:11:07 +02:00
parent eca14c5d08
commit 063d7e4637
2 changed files with 12 additions and 6 deletions

View file

@ -4,6 +4,7 @@ import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig";
import TagRenderingQuestion from "../../../UI/Popup/TagRenderingQuestion";
import {UIEventSource} from "../../../Logic/UIEventSource";
import { expect } from 'chai';
import Locale from "../../../UI/i18n/Locale";
describe("TagRenderingQuestion", () => {
@ -27,6 +28,7 @@ describe("TagRenderingQuestion", () => {
it("should have a freeform text field with a type explanation", () => {
Locale.language.setData("en")
const configJson = <TagRenderingConfigJson>{
id: "test-tag-rendering",
question: "Question?",

View file

@ -28,23 +28,27 @@ function initDownloads(query: string){
describe("GenerateCache", () => {
it("should generate a cached file for the Natuurpunt-theme", async () => {
if (existsSync("/tmp/np-cache")) {
ScriptUtils.readDirRecSync("/tmp/np-cache").forEach(p => unlinkSync(p))
rmdirSync("/tmp/np-cache")
// We use /var/tmp instead of /tmp, as more OS's (such as MAC) have this
if(!existsSync("/var/tmp")){
console.log("Not executing caching test: no temp directory found")
}
mkdirSync("/tmp/np-cache")
if (existsSync("/var/tmp/np-cache")) {
ScriptUtils.readDirRecSync("/var/tmp/np-cache").forEach(p => unlinkSync(p))
rmdirSync("/var/tmp/np-cache")
}
mkdirSync("/var/tmp/np-cache")
initDownloads(
"(nwr%5B%22amenity%22%3D%22toilets%22%5D%3Bnwr%5B%22amenity%22%3D%22parking%22%5D%3Bnwr%5B%22amenity%22%3D%22bench%22%5D%3Bnwr%5B%22id%22%3D%22location_track%22%5D%3Bnwr%5B%22id%22%3D%22gps%22%5D%3Bnwr%5B%22information%22%3D%22board%22%5D%3Bnwr%5B%22leisure%22%3D%22picnic_table%22%5D%3Bnwr%5B%22man_made%22%3D%22watermill%22%5D%3Bnwr%5B%22user%3Ahome%22%3D%22yes%22%5D%3Bnwr%5B%22user%3Alocation%22%3D%22yes%22%5D%3Bnwr%5B%22leisure%22%3D%22nature_reserve%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22boundary%22%3D%22protected_area%22%5D%5B%22protect_class%22!%3D%2298%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22information%22%3D%22visitor_centre%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22information%22%3D%22office%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22route%22~%22%5E.*foot.*%24%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22route%22~%22%5E.*hiking.*%24%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22route%22~%22%5E.*bycicle.*%24%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22route%22~%22%5E.*horse.*%24%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22leisure%22%3D%22bird_hide%22%5D%5B%22operator%22~%22%5E.*%5BnN%5Datuurpunt.*%24%22%5D%3Bnwr%5B%22amenity%22%3D%22drinking_water%22%5D%5B%22access%22!%3D%22permissive%22%5D%5B%22access%22!%3D%22private%22%5D%3B)%3Bout%20body%3Bout%20meta%3B%3E%3Bout%20skel%20qt%3B"
);
await main([
"natuurpunt",
"12",
"/tmp/np-cache",
"/var/tmp/np-cache",
"51.15423567022531", "3.250579833984375", "51.162821593316934", "3.262810707092285",
"--generate-point-overview", "nature_reserve,visitor_information_centre"
])
await ScriptUtils.sleep(500)
const birdhides = JSON.parse(readFileSync("/tmp/np-cache/natuurpunt_birdhide_12_2085_1368.geojson", "UTF8"))
const birdhides = JSON.parse(readFileSync("/var/tmp/np-cache/natuurpunt_birdhide_12_2085_1368.geojson", "UTF8"))
expect(birdhides.features.length).deep.equal(5)
expect(birdhides.features.some(f => f.properties.id === "node/5158056232"), "Didn't find birdhide node/5158056232 ").true