Skip to content

Commit

Permalink
eslint: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 authored and erictheise committed Jan 1, 2024
1 parent 5ac1f32 commit c9198eb
Show file tree
Hide file tree
Showing 7 changed files with 315 additions and 319 deletions.
66 changes: 33 additions & 33 deletions tests/test.autorepair.josm.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {afterEach, describe, expect, it, vi} from "vitest";
import ide from "../js/ide";

describe("ide.autorepair.josm", function () {
describe("ide.autorepair.josm", () => {
afterEach(() => {
vi.restoreAllMocks();
});
// repair non-xml output data format: xml query
it("repair non-xml output data format (xml query)", function () {
var examples = [
it("repair non-xml output data format (xml query)", () => {
const examples = [
{
// basic case
inp: '<osm-script output="json"></osm-script>',
Expand All @@ -29,17 +29,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// repair non-xml output data format: ql query
it("repair non-xml output data format (OverpassQL query)", function () {
var examples = [
it("repair non-xml output data format (OverpassQL query)", () => {
const examples = [
{
// basic case
inp: "[out:json];",
Expand All @@ -64,17 +64,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// repair missing xml+meta infomation: xml query
it("repair missing meta information (xml query)", function () {
var examples = [
it("repair missing meta information (xml query)", () => {
const examples = [
{
// trivial case
inp: "<print/>",
Expand All @@ -95,17 +95,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// repair missing xml+meta infomation: ql query
it("repair missing meta information (OverpassQL query)", function () {
var examples = [
it("repair missing meta information (OverpassQL query)", () => {
const examples = [
{
// trivial case
inp: "out;",
Expand Down Expand Up @@ -136,17 +136,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// overpass complex geometries
it("repair overpass geometry options (xml query)", function () {
var examples = [
it("repair overpass geometry options (xml query)", () => {
const examples = [
{
// center geometry
inp: '<print mode="meta" geometry="center"/>',
Expand Down Expand Up @@ -179,17 +179,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// overpass complex geometries
it("repair overpass geometry options (OverpassQL query)", function () {
var examples = [
it("repair overpass geometry options (OverpassQL query)", () => {
const examples = [
{
// center geometry
inp: "out meta center;",
Expand Down Expand Up @@ -222,17 +222,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// do not repair statements in comments
it("do not repair statements in comments (xml query)", function () {
var examples = [
it("do not repair statements in comments (xml query)", () => {
const examples = [
{
// <print> in xml comment
inp: "<!--<print/>-->",
Expand All @@ -245,17 +245,17 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// do not repair statements in comments
it("do not repair statements in comments (overpassQL query)", function () {
var examples = [
it("do not repair statements in comments (overpassQL query)", () => {
const examples = [
{
// multiline comment
inp: "/*out;*/",
Expand All @@ -268,8 +268,8 @@ describe("ide.autorepair.josm", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("xml+metadata");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
Expand Down
34 changes: 17 additions & 17 deletions tests/test.autorepair.recurse.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {afterEach, describe, expect, it, vi} from "vitest";
import ide from "../js/ide";

describe("ide.autorepair.recurse", function () {
describe("ide.autorepair.recurse", () => {
afterEach(() => {
vi.restoreAllMocks();
});
// autocomplete missing recurse statements: xml query
it("autocomplete xml query", function () {
var examples = [
it("autocomplete xml query", () => {
const examples = [
{
// trivial case
inp: "<print/>",
Expand All @@ -30,17 +30,17 @@ describe("ide.autorepair.recurse", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("no visible data");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// autocomplete missing recurse statements: OverpassQL query
it("autocomplete OverpassQL query", function () {
var examples = [
it("autocomplete OverpassQL query", () => {
const examples = [
{
// trivial case
inp: "out;",
Expand Down Expand Up @@ -75,34 +75,34 @@ describe("ide.autorepair.recurse", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "OverpassQL");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("no visible data");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// do not autocomplete in comments (xml query)
it("do not autocomplete in comments (xml query)", function () {
var examples = [
it("do not autocomplete in comments (xml query)", () => {
const examples = [
{
inp: "<!--<print/>-->",
outp: "<!--<print/>-->"
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("no visible data");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
}
});

// do not autocomplete in comments (OverpassQL query)
it("do not autocomplete in comments (OverpassQL query)", function () {
var examples = [
it("do not autocomplete in comments (OverpassQL query)", () => {
const examples = [
{
// multiline comments
inp: "/*out;*/",
Expand All @@ -115,8 +115,8 @@ describe("ide.autorepair.recurse", function () {
}
];
vi.spyOn(ide, "getQueryLang").mockImplementation(() => "xml");
for (var i = 0; i < examples.length; i++) {
var setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
for (let i = 0; i < examples.length; i++) {
const setQuery = vi.spyOn(ide, "setQuery").mockImplementation(() => {});
vi.spyOn(ide, "getRawQuery").mockImplementation(() => examples[i].inp);
ide.repairQuery("no visible data");
expect(setQuery).toHaveBeenCalledWith(examples[i].outp);
Expand Down
Loading

0 comments on commit c9198eb

Please sign in to comment.