thelounge/test/client/js/constantsTest.ts

41 lines
1.3 KiB
TypeScript
Raw Normal View History

import {expect} from "chai";
import constants from "../../../client/js/constants";
import {describe} from "mocha";
2017-11-29 06:31:03 +01:00
describe("client-side constants", function () {
describe(".colorCodeMap", function () {
it("should be a non-empty array", function () {
expect(constants.colorCodeMap).to.be.an("array").of.length(16);
2017-11-29 06:31:03 +01:00
});
it("should be made of pairs of strings", function () {
2019-12-02 11:10:17 +01:00
constants.colorCodeMap.forEach(([code, name]) => {
expect(code)
2019-07-17 11:33:59 +02:00
.to.be.a("string")
.that.match(/[0-9]{2}/);
2019-12-02 11:10:17 +01:00
expect(name).to.be.a("string");
2017-11-29 06:31:03 +01:00
});
});
});
describe(".condensedTypes", function () {
it("should be a non-empty array", function () {
2019-12-17 11:48:12 +01:00
expect(constants.condensedTypes).to.be.an.instanceof(Set).that.is.not.empty;
2017-11-29 06:31:03 +01:00
});
it("should only contain ASCII strings", function () {
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'type' implicitly has an 'any' type.
constants.condensedTypes.forEach((type) => {
expect(type).to.be.a("string").that.does.match(/^\w+$/);
});
2017-11-29 06:31:03 +01:00
});
});
describe(".timeFormats", function () {
it("should be objects of strings", function () {
2017-11-29 06:31:03 +01:00
expect(constants.timeFormats.msgDefault).to.be.an("string").that.is.not.empty;
expect(constants.timeFormats.msgWithSeconds).to.be.an("string").that.is.not.empty;
});
});
});