Skip to content

Commit

Permalink
Run Prettier on code base.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Jan 2, 2024
1 parent fc14f9a commit 307a534
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 59 deletions.
2 changes: 1 addition & 1 deletion js/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $(document).ready(() => {
disable_poiomatic: false
};
const ide = {
map: (undefined as unknown) as L.Map,
map: undefined as unknown as L.Map,
mapcss: "",
async getQuery(): Promise<string> {
let query = settings.code["overpass"];
Expand Down
51 changes: 17 additions & 34 deletions tests/test.autorepair.josm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ describe("ide.autorepair.josm", () => {
{
// basic case
inp: '<osm-script output="json"></osm-script>',
outp:
'<osm-script output="xml"><!-- fixed by auto repair --></osm-script>'
outp: '<osm-script output="xml"><!-- fixed by auto repair --></osm-script>'
},
{
// preserve other osm-script parameters
inp: '<osm-script output="json" timeout="25"></osm-script>',
outp:
'<osm-script output="xml" timeout="25"><!-- fixed by auto repair --></osm-script>'
outp: '<osm-script output="xml" timeout="25"><!-- fixed by auto repair --></osm-script>'
},
{
// more complex real world example
inp:
'<osm-script output="json">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"/>\n</osm-script>',
outp:
'<osm-script output="xml"><!-- fixed by auto repair -->\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"/>\n</osm-script>'
inp: '<osm-script output="json">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"/>\n</osm-script>',
outp: '<osm-script output="xml"><!-- fixed by auto repair -->\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"/>\n</osm-script>'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
Expand Down Expand Up @@ -57,10 +53,8 @@ describe("ide.autorepair.josm", () => {
},
{
// more complex real world example
inp:
'/*bla*/\n[out:json];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;',
outp:
'/*bla*/\n[out:xml];/*fixed by auto repair*/\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;'
inp: '/*bla*/\n[out:json];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;',
outp: '/*bla*/\n[out:xml];/*fixed by auto repair*/\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
Expand All @@ -83,15 +77,12 @@ describe("ide.autorepair.josm", () => {
{
// trivial case 2
inp: '<osm-script output="xml"><print/></osm-script>',
outp:
'<osm-script output="xml"><print mode="meta"></print><!-- fixed by auto repair --></osm-script>'
outp: '<osm-script output="xml"><print mode="meta"></print><!-- fixed by auto repair --></osm-script>'
},
{
// more complex real world example
inp:
'<osm-script output="xml">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="body" order="quadtile"/>\n</osm-script>',
outp:
'<osm-script output="xml">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"></print><!-- fixed by auto repair -->\n</osm-script>'
inp: '<osm-script output="xml">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="body" order="quadtile"/>\n</osm-script>',
outp: '<osm-script output="xml">\n <query type="node">\n <has-kv k="amenity" v="drinking_water"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="meta" order="quadtile"></print><!-- fixed by auto repair -->\n</osm-script>'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
Expand Down Expand Up @@ -119,8 +110,7 @@ describe("ide.autorepair.josm", () => {
{
// non meta output mode
inp: "out skel;out body;out ids;out tags;",
outp:
"out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/"
outp: "out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/out meta;/*fixed by auto repair*/"
},
{
// combined with other output options
Expand All @@ -129,10 +119,8 @@ describe("ide.autorepair.josm", () => {
},
{
// more complex real world example
inp:
'/*bla*/\n[out:xml];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out qt;',
outp:
'/*bla*/\n[out:xml];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;/*fixed by auto repair*/'
inp: '/*bla*/\n[out:xml];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out qt;',
outp: '/*bla*/\n[out:xml];\nway\n ["amenity"]\n ({{bbox}})\n->.foo;\n.foo out meta qt;/*fixed by auto repair*/'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
Expand All @@ -150,32 +138,27 @@ describe("ide.autorepair.josm", () => {
{
// center geometry
inp: '<print mode="meta" geometry="center"/>',
outp:
'<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
outp: '<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
},
{
// bounds geometry
inp: '<print mode="meta" geometry="bounds"/>',
outp:
'<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
outp: '<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
},
{
// full geometry
inp: '<print mode="meta" geometry="full"/>',
outp:
'<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
outp: '<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
},
{
// full geometry with from output mode
inp: '<print mode="body" geometry="full"/>',
outp:
'<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
outp: '<union><item/><recurse type="down"/></union><print mode="meta"></print><!-- fixed by auto repair -->'
},
{
// full geometry with named input set
inp: '<print from="foo" mode="meta" geometry="full"/>',
outp:
'<union into="foo"><item set="foo"/><recurse from="foo" type="down"/></union><print from="foo" mode="meta"></print><!-- fixed by auto repair -->'
outp: '<union into="foo"><item set="foo"/><recurse from="foo" type="down"/></union><print from="foo" mode="meta"></print><!-- fixed by auto repair -->'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
Expand Down
36 changes: 12 additions & 24 deletions tests/test.autorepair.recurse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ describe("ide.autorepair.recurse", () => {
{
// trivial case
inp: "<print/>",
outp:
'\n<!-- added by auto repair -->\n<union>\n <item/>\n <recurse type="down"/>\n</union>\n<!-- end of auto repair --><print/>'
outp: '\n<!-- added by auto repair -->\n<union>\n <item/>\n <recurse type="down"/>\n</union>\n<!-- end of auto repair --><print/>'
},
{
// simple real life example
inp:
'<osm-script output="json">\n <query type="way">\n <has-kv k="name"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="body" order="quadtile"/>\n</osm-script>',
outp:
'<osm-script output="json">\n <query type="way">\n <has-kv k="name"/>\n <bbox-query {{bbox}}/>\n </query>\n <!-- added by auto repair -->\n <union>\n <item/>\n <recurse type="down"/>\n </union>\n <!-- end of auto repair -->\n <print mode="body" order="quadtile"/>\n</osm-script>'
inp: '<osm-script output="json">\n <query type="way">\n <has-kv k="name"/>\n <bbox-query {{bbox}}/>\n </query>\n <print mode="body" order="quadtile"/>\n</osm-script>',
outp: '<osm-script output="json">\n <query type="way">\n <has-kv k="name"/>\n <bbox-query {{bbox}}/>\n </query>\n <!-- added by auto repair -->\n <union>\n <item/>\n <recurse type="down"/>\n </union>\n <!-- end of auto repair -->\n <print mode="body" order="quadtile"/>\n</osm-script>'
},
{
// complex example with multiple prints and named input sets
inp:
'<query type="way" into="foo">\n <has-kv k="amenity"/>\n <bbox-query {{bbox}}/>\n</query>\n<query type="way" into="bar">\n <has-kv k="building"/>\n <bbox-query {{bbox}}/>\n</query>\n<print from="foo"/>\n<print from="bar" mode="meta"/>',
outp:
'<query type="way" into="foo">\n <has-kv k="amenity"/>\n <bbox-query {{bbox}}/>\n</query>\n<query type="way" into="bar">\n <has-kv k="building"/>\n <bbox-query {{bbox}}/>\n</query>\n<!-- added by auto repair -->\n<union into="foo">\n <item set="foo"/>\n <recurse from="foo" type="down"/>\n</union>\n<!-- end of auto repair -->\n<print from="foo"/>\n<!-- added by auto repair -->\n<union into="bar">\n <item set="bar"/>\n <recurse from="bar" type="down"/>\n</union>\n<!-- end of auto repair -->\n<print from="bar" mode="meta"/>'
inp: '<query type="way" into="foo">\n <has-kv k="amenity"/>\n <bbox-query {{bbox}}/>\n</query>\n<query type="way" into="bar">\n <has-kv k="building"/>\n <bbox-query {{bbox}}/>\n</query>\n<print from="foo"/>\n<print from="bar" mode="meta"/>',
outp: '<query type="way" into="foo">\n <has-kv k="amenity"/>\n <bbox-query {{bbox}}/>\n</query>\n<query type="way" into="bar">\n <has-kv k="building"/>\n <bbox-query {{bbox}}/>\n</query>\n<!-- added by auto repair -->\n<union into="foo">\n <item set="foo"/>\n <recurse from="foo" type="down"/>\n</union>\n<!-- end of auto repair -->\n<print from="foo"/>\n<!-- added by auto repair -->\n<union into="bar">\n <item set="bar"/>\n <recurse from="bar" type="down"/>\n</union>\n<!-- end of auto repair -->\n<print from="bar" mode="meta"/>'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
Expand All @@ -48,30 +43,23 @@ describe("ide.autorepair.recurse", () => {
},
{
// simple real life example
inp:
'/*This is the drinking water example in OverpassQL.*/\n(\n way["name"]({{bbox}})\n);\nout;',
outp:
'/*This is the drinking water example in OverpassQL.*/\n(\n way["name"]({{bbox}})\n);\n/*added by auto repair*/\n(._;>;);\n/*end of auto repair*/\nout;'
inp: '/*This is the drinking water example in OverpassQL.*/\n(\n way["name"]({{bbox}})\n);\nout;',
outp: '/*This is the drinking water example in OverpassQL.*/\n(\n way["name"]({{bbox}})\n);\n/*added by auto repair*/\n(._;>;);\n/*end of auto repair*/\nout;'
},
{
// simple query with coordinates
inp:
'(way["name"](50.75267740365953,7.085511088371277,50.755728421888925,7.0877212285995475));out;',
outp:
'(way["name"](50.75267740365953,7.085511088371277,50.755728421888925,7.0877212285995475));/*added by auto repair*/(._;>;);/*end of auto repair*/out;'
inp: '(way["name"](50.75267740365953,7.085511088371277,50.755728421888925,7.0877212285995475));out;',
outp: '(way["name"](50.75267740365953,7.085511088371277,50.755728421888925,7.0877212285995475));/*added by auto repair*/(._;>;);/*end of auto repair*/out;'
},
{
// complex example with multiple prints and named input sets
inp:
'way\n ["amenity"]\n ({{bbox}})\n->.foo;\nway\n ["building"]\n ({{bbox}})\n->.bar;\n.foo out;\n.bar out meta;',
outp:
'way\n ["amenity"]\n ({{bbox}})\n->.foo;\nway\n ["building"]\n ({{bbox}})\n->.bar;\n/*added by auto repair*/\n(.foo;.foo >;)->.foo;\n/*end of auto repair*/\n.foo out;\n/*added by auto repair*/\n(.bar;.bar >;)->.bar;\n/*end of auto repair*/\n.bar out meta;'
inp: 'way\n ["amenity"]\n ({{bbox}})\n->.foo;\nway\n ["building"]\n ({{bbox}})\n->.bar;\n.foo out;\n.bar out meta;',
outp: 'way\n ["amenity"]\n ({{bbox}})\n->.foo;\nway\n ["building"]\n ({{bbox}})\n->.bar;\n/*added by auto repair*/\n(.foo;.foo >;)->.foo;\n/*end of auto repair*/\n.foo out;\n/*added by auto repair*/\n(.bar;.bar >;)->.bar;\n/*end of auto repair*/\n.bar out meta;'
},
{
// example with the term "...out..." in string parameters
inp: 'way({{bbox}})[junction=roundabout][name!="out"];out;',
outp:
'way({{bbox}})[junction=roundabout][name!="out"];/*added by auto repair*/(._;>;);/*end of auto repair*/out;'
outp: 'way({{bbox}})[junction=roundabout][name!="out"];/*added by auto repair*/(._;>;);/*end of auto repair*/out;'
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
Expand Down

0 comments on commit 307a534

Please sign in to comment.