forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
@ -1,15 +1,13 @@
|
|||
import {describe} from 'mocha'
|
||||
import {TagRenderingConfigJson} from "../../../Models/ThemeConfig/Json/TagRenderingConfigJson";
|
||||
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";
|
||||
import { describe } from "mocha"
|
||||
import { TagRenderingConfigJson } from "../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
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", () => {
|
||||
|
||||
it("should have a freeform text field with the user defined placeholder", () => {
|
||||
|
||||
const configJson = <TagRenderingConfigJson>{
|
||||
id: "test-tag-rendering",
|
||||
question: "Question?",
|
||||
|
@ -17,17 +15,18 @@ describe("TagRenderingQuestion", () => {
|
|||
freeform: {
|
||||
key: "capacity",
|
||||
type: "pnat",
|
||||
placeholder: "Some user defined placeholder"
|
||||
}
|
||||
placeholder: "Some user defined placeholder",
|
||||
},
|
||||
}
|
||||
const config = new TagRenderingConfig(configJson, "test")
|
||||
const ui = new TagRenderingQuestion( new UIEventSource<any>({}), config)
|
||||
const ui = new TagRenderingQuestion(new UIEventSource<any>({}), config)
|
||||
const html = ui.ConstructElement()
|
||||
expect(html.getElementsByTagName("input")[0]["placeholder"]).eq("Some user defined placeholder")
|
||||
expect(html.getElementsByTagName("input")[0]["placeholder"]).eq(
|
||||
"Some user defined placeholder"
|
||||
)
|
||||
})
|
||||
|
||||
it("should have a freeform text field with a type explanation", () => {
|
||||
|
||||
Locale.language.setData("en")
|
||||
const configJson = <TagRenderingConfigJson>{
|
||||
id: "test-tag-rendering",
|
||||
|
@ -36,12 +35,13 @@ describe("TagRenderingQuestion", () => {
|
|||
freeform: {
|
||||
key: "capacity",
|
||||
type: "pnat",
|
||||
}
|
||||
},
|
||||
}
|
||||
const config = new TagRenderingConfig(configJson, "test")
|
||||
const ui = new TagRenderingQuestion( new UIEventSource<any>({}), config)
|
||||
const ui = new TagRenderingQuestion(new UIEventSource<any>({}), config)
|
||||
const html = ui.ConstructElement()
|
||||
expect(html.getElementsByTagName("input")[0]["placeholder"])
|
||||
.eq("capacity (a positive, whole number)")
|
||||
expect(html.getElementsByTagName("input")[0]["placeholder"]).eq(
|
||||
"capacity (a positive, whole number)"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
import {describe} from 'mocha'
|
||||
import SpecialVisualizations from "../../UI/SpecialVisualizations";
|
||||
import {expect} from "chai";
|
||||
import { describe } from "mocha"
|
||||
import SpecialVisualizations from "../../UI/SpecialVisualizations"
|
||||
import { expect } from "chai"
|
||||
|
||||
describe("SpecialVisualisations", () => {
|
||||
|
||||
describe("predifined special visualisations", () => {
|
||||
it("should not have an argument called 'type'", () => {
|
||||
const specials = SpecialVisualizations.specialVisualizations
|
||||
for (const special of specials) {
|
||||
expect(special.funcName).not.eq('type', "A special visualisation is not allowed to be named 'type', as this will conflict with the 'special'-blocks")
|
||||
expect(special.funcName).not.eq(
|
||||
"type",
|
||||
"A special visualisation is not allowed to be named 'type', as this will conflict with the 'special'-blocks"
|
||||
)
|
||||
for (const arg of special.args) {
|
||||
expect(arg.name).not.eq('type', "An argument is not allowed to be called 'type', as this will conflict with the 'special'-blocks")
|
||||
expect(arg.name).not.eq(
|
||||
"type",
|
||||
"An argument is not allowed to be called 'type', as this will conflict with the 'special'-blocks"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import {describe} from 'mocha'
|
||||
import ValidatedTextField from "../../UI/Input/ValidatedTextField";
|
||||
import {fail} from "assert";
|
||||
import Translations from "../../UI/i18n/Translations";
|
||||
import { describe } from "mocha"
|
||||
import ValidatedTextField from "../../UI/Input/ValidatedTextField"
|
||||
import { fail } from "assert"
|
||||
import Translations from "../../UI/i18n/Translations"
|
||||
|
||||
describe("ValidatedTextFields", () => {
|
||||
|
||||
it("should all have description in the translations", () => {
|
||||
const ts = Translations.t.validation;
|
||||
const ts = Translations.t.validation
|
||||
const missingTranslations = Array.from(ValidatedTextField.allTypes.keys())
|
||||
.filter(key => ts[key] === undefined || ts[key].description === undefined)
|
||||
.filter(key => key !== "distance")
|
||||
.filter((key) => ts[key] === undefined || ts[key].description === undefined)
|
||||
.filter((key) => key !== "distance")
|
||||
if (missingTranslations.length > 0) {
|
||||
fail("The validated text fields don't have a description defined in en.json for "+missingTranslations.join(", ")+". (Did you just add one? Run `npm run generate:translations`)")
|
||||
fail(
|
||||
"The validated text fields don't have a description defined in en.json for " +
|
||||
missingTranslations.join(", ") +
|
||||
". (Did you just add one? Run `npm run generate:translations`)"
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue