improve tests (#2923)

use es6 syntax in all tests, split weather tests, remove callbacks
This commit is contained in:
Karsten Hassel
2022-10-04 10:15:24 +02:00
committed by GitHub
parent 7694d6fa86
commit f04d578704
41 changed files with 751 additions and 840 deletions

View File

@@ -1,34 +1,34 @@
const Utils = require("../../../js/utils.js");
const colors = require("colors/safe");
describe("Utils", function () {
describe("colors", function () {
describe("Utils", () => {
describe("colors", () => {
const colorsEnabled = colors.enabled;
afterEach(function () {
afterEach(() => {
colors.enabled = colorsEnabled;
});
it("should have info, warn and error properties", function () {
it("should have info, warn and error properties", () => {
expect(Utils.colors).toHaveProperty("info");
expect(Utils.colors).toHaveProperty("warn");
expect(Utils.colors).toHaveProperty("error");
});
it("properties should be functions", function () {
it("properties should be functions", () => {
expect(typeof Utils.colors.info).toBe("function");
expect(typeof Utils.colors.warn).toBe("function");
expect(typeof Utils.colors.error).toBe("function");
});
it("should print colored message in supported consoles", function () {
it("should print colored message in supported consoles", () => {
colors.enabled = true;
expect(Utils.colors.info("some informations")).toBe("\u001b[34msome informations\u001b[39m");
expect(Utils.colors.warn("a warning")).toBe("\u001b[33ma warning\u001b[39m");
expect(Utils.colors.error("ERROR!")).toBe("\u001b[31mERROR!\u001b[39m");
});
it("should print message in unsupported consoles", function () {
it("should print message in unsupported consoles", () => {
colors.enabled = false;
expect(Utils.colors.info("some informations")).toBe("some informations");
expect(Utils.colors.warn("a warning")).toBe("a warning");