tingle-bot/test/weather.spec.ts

103 lines
3.1 KiB
TypeScript
Raw Normal View History

import { describe, it, expect } from "vitest";
import { precipitations } from "../src/data/weather/precipitations.ts";
import { specials } from "../src/data/weather/specials.ts";
import { temperatures } from "../src/data/weather/temperatures.ts";
import { winds } from "../src/data/weather/winds.ts";
describe("weather Tests", () => {
describe("temperature", () => {
const temps = new Set(temperatures.map((element) => {
return element.name;
}));
it("temperatures should be unique", () => {
expect(temps.size, "temperatures are not unique!").toBe(
temperatures.length,
);
});
});
describe("winds", () => {
const wind = new Set(winds.map((element) => {
return element.name;
}));
it("winds should be unique", () => {
expect(wind.size, "winds are not unique!").toBe(winds.length);
});
});
describe("precipitations", () => {
const precip = new Set(precipitations.map((element) => {
return element.name;
}));
it("precipitations should be unique", () => {
expect(precip.size, "precipitations are not unique!").toBe(
precipitations.length,
);
});
for (const precipitation of precipitations) {
it(`${precipitation.name} should have unique temps`, () => {
if (precipitation.temps === "any") {
return;
}
const temps = new Set(precipitation.temps);
expect(temps.size, `${precipitation.name} temps are not unique!`).toBe(
precipitation.temps.length,
);
});
it(`${precipitation.name} should have unique winds`, () => {
if (precipitation.winds === "any") {
return;
}
const winds = new Set(precipitation.winds);
expect(winds.size, `${precipitation.name} winds are not unique!`).toBe(
precipitation.winds.length,
);
});
}
});
describe("specials", () => {
const spec = new Set(specials.map((element) => {
return element.name;
}));
it("specials should be unique", () => {
expect(spec.size, "specials are not unique!").toBe(specials.length);
});
for (const special of specials) {
it(`${special.name} should have unique temps`, () => {
if (special.temps === "any") {
return;
}
const temps = new Set(special.temps);
expect(temps.size, `${special.name} temps are not unique!`).toBe(
special.temps.length,
);
});
it(`${special.name} should have unique winds`, () => {
if (special.winds === "any") {
return;
}
const winds = new Set(special.winds);
expect(special.winds, "Special winds are not unique!").toHaveLength(
winds.size,
);
});
it(`${special.name} should have unique precipitation`, () => {
if (special.precipitations === "any") {
return;
}
const precip = new Set(special.precipitations);
expect(
precip.size,
`${special.name} precipitation is not unique!`,
).toBe(special.precipitations.length);
});
}
});
});