Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
require: "test-mocha/testconf.js",
timeout: 10000,
};
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"lint:lit": "lit-analyzer \"**/src/**/*.ts\" --format markdown --outFile result.md",
"lint": "yarn run lint:eslint && yarn run lint:prettier && yarn run lint:types",
"format": "yarn run format:eslint && yarn run format:prettier",
"mocha": "node_modules/.bin/ts-mocha -p test-mocha/tsconfig.test.json --opts test-mocha/mocha.opts",
"mocha": "ts-mocha -p test-mocha/tsconfig.test.json \"test-mocha/**/*.ts\"",
"test": "yarn run lint && yarn run mocha"
},
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
Expand Down Expand Up @@ -165,23 +165,24 @@
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.2",
"@types/chai": "^4.1.7",
"@types/chai": "^4.2.18",
"@types/chromecast-caf-receiver": "^5.0.11",
"@types/chromecast-caf-sender": "^1.0.3",
"@types/js-yaml": "^4.0.1",
"@types/leaflet": "^1.7.0",
"@types/leaflet-draw": "^1.0.3",
"@types/marked": "^1.2.2",
"@types/mocha": "^7.0.2",
"@types/mocha": "^8.2.2",
"@types/resize-observer-browser": "^0.1.3",
"@types/sinon": "^10.0.0",
"@types/sortablejs": "^1.10.6",
"@types/webspeechapi": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@web/dev-server": "^0.0.24",
"@web/dev-server-rollup": "^0.2.11",
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"chai": "^4.3.4",
"cpx": "^1.5.0",
"del": "^4.0.0",
"eslint": "^7.25.0",
Expand Down Expand Up @@ -209,7 +210,7 @@
"magic-string": "^0.25.7",
"map-stream": "^0.0.7",
"merge-stream": "^1.0.1",
"mocha": "^7.2.0",
"mocha": "^8.4.0",
"object-hash": "^2.0.3",
"open": "^7.0.4",
"prettier": "^2.0.4",
Expand All @@ -220,12 +221,12 @@
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-visualizer": "^4.0.4",
"serve": "^11.3.0",
"sinon": "^7.3.1",
"sinon": "^11.0.0",
"source-map-url": "^0.4.0",
"systemjs": "^6.3.2",
"terser-webpack-plugin": "^5.1.1",
"ts-lit-plugin": "^1.2.1",
"ts-mocha": "^7.0.0",
"ts-mocha": "^8.0.0",
"typescript": "^4.2.4",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test-mocha/common/entity/extract_views.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";
import { DEFAULT_VIEW_ENTITY_ID } from "../../../src/common/const";
import { extractViews } from "../../../src/common/entity/extract_views";
import { createEntities, createView } from "./test_util";
Expand Down
2 changes: 1 addition & 1 deletion test-mocha/common/entity/get_group_entities.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import { getGroupEntities } from "../../../src/common/entity/get_group_entities";

Expand Down
2 changes: 1 addition & 1 deletion test-mocha/common/entity/get_view_entities.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import { getViewEntities } from "../../../src/common/entity/get_view_entities";

Expand Down
2 changes: 1 addition & 1 deletion test-mocha/common/entity/split_by_groups.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import { splitByGroups } from "../../../src/common/entity/split_by_groups";

Expand Down
4 changes: 2 additions & 2 deletions test-mocha/common/entity/timer_time_remaining_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import * as sinon from "sinon";
import { useFakeTimers } from "sinon";

import { timerTimeRemaining } from "../../../src/data/timer";

Expand Down Expand Up @@ -31,7 +31,7 @@ describe("timerTimeRemaining", () => {
describe("active timers", () => {
let clock;
beforeEach(() => {
clock = sinon.useFakeTimers(new Date("2018-01-17T16:15:30Z"));
clock = useFakeTimers(new Date("2018-01-17T16:15:30Z"));
});
afterEach(() => {
clock.restore();
Expand Down
2 changes: 1 addition & 1 deletion test-mocha/common/util/parse_aspect_ratio_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import parseAspectRatio from "../../../src/common/util/parse-aspect-ratio";

Expand Down
2 changes: 1 addition & 1 deletion test-mocha/external_app/external_messaging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import {
ExternalMessaging,
Expand Down
6 changes: 4 additions & 2 deletions test-mocha/hassio/create_session.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";
import { createHassioSession } from "../../src/data/hassio/ingress";

describe("Create hassio session", function () {
Expand Down Expand Up @@ -44,7 +44,9 @@ describe("Create hassio session", function () {
it("Test fail to create", async function () {
const createSessionPromise = createHassioSession({
// @ts-ignore
callApi: async function () {},
callApi: async function () {
// noop
},
}).then(
() => true,
() => false
Expand Down
4 changes: 0 additions & 4 deletions test-mocha/mocha.opts

This file was deleted.

12 changes: 6 additions & 6 deletions test-mocha/panels/lovelace/editor/config-util.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";

import {
swapCard,
Expand Down Expand Up @@ -43,7 +43,7 @@ describe("swapCard", () => {
};

const result = swapCard(config, [0, 0], [1, 1]);
const expected = {
const expected: LovelaceConfig = {
views: [
{
cards: [{ type: "v2-c2" }, { type: "v1-c2" }],
Expand All @@ -69,7 +69,7 @@ describe("moveCard", () => {
};

const result = moveCard(config, [1, 0], [0]);
const expected = {
const expected: LovelaceConfig = {
views: [
{
cards: [{ type: "card1" }],
Expand All @@ -95,7 +95,7 @@ describe("moveCard", () => {
};

const result = moveCard(config, [1, 0], [0]);
const expected = {
const expected: LovelaceConfig = {
views: [
{
cards: [{ type: "v1-c1" }, { type: "v1-c2" }, { type: "v2-c1" }],
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("swapView", () => {
};

const result = swapView(config, 1, 0);
const expected = {
const expected: LovelaceConfig = {
views: [
{
title: "view2",
Expand Down Expand Up @@ -177,7 +177,7 @@ describe("swapView", () => {
};

const result = swapView(config, 0, 0);
const expected = {
const expected: LovelaceConfig = {
views: [
{
title: "view1",
Expand Down
22 changes: 11 additions & 11 deletions test-mocha/util/calculate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";
import {
getValueInPercentage,
normalize,
Expand All @@ -7,19 +7,19 @@ import {

describe("Calculate tests", function () {
it("Test getValueInPercentage", function () {
assert.equal(getValueInPercentage(10, 0, 100), 10);
assert.equal(getValueInPercentage(120, 0, 100), 120);
assert.equal(getValueInPercentage(-10, 0, 100), -10);
assert.equal(getValueInPercentage(10.33333, 0, 100), 10.33333);
assert.strictEqual(getValueInPercentage(10, 0, 100), 10);
assert.strictEqual(getValueInPercentage(120, 0, 100), 120);
assert.strictEqual(getValueInPercentage(-10, 0, 100), -10);
assert.strictEqual(getValueInPercentage(10.33333, 0, 100), 10.33333);
});
it("Test normalize", function () {
assert.equal(normalize(10, 0, 100), 10);
assert.equal(normalize(1, 10, 100), 10);
assert.equal(normalize(100, 0, 10), 10);
assert.strictEqual(normalize(10, 0, 100), 10);
assert.strictEqual(normalize(1, 10, 100), 10);
assert.strictEqual(normalize(100, 0, 10), 10);
});
it("Test roundWithOneDecimal", function () {
assert.equal(roundWithOneDecimal(10), 10);
assert.equal(roundWithOneDecimal(10.3), 10.3);
assert.equal(roundWithOneDecimal(10.3333), 10.3);
assert.strictEqual(roundWithOneDecimal(10), 10);
assert.strictEqual(roundWithOneDecimal(10.3), 10.3);
assert.strictEqual(roundWithOneDecimal(10.3333), 10.3);
});
});
2 changes: 1 addition & 1 deletion test-mocha/util/generate-brands-url-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";
import { brandsUrl } from "../../src/util/brands-url";

describe("Generate brands Url", function () {
Expand Down
2 changes: 1 addition & 1 deletion test-mocha/util/generate-documentation-url.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import { assert } from "chai";
import { documentationUrl } from "../../src/util/documentation-url";

describe("Generate documentation URL", function () {
Expand Down
Loading