Skip to content

Commit

Permalink
fix(test): add some spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHabenicht committed Jan 9, 2022
1 parent 6ec994c commit ed4eccc
Show file tree
Hide file tree
Showing 5 changed files with 1,408 additions and 456 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
fetch-depth: 0
- name: Install dependencies
run: npm ci
- name: Test
run: npm test
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion MMM-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Module.register("MMM-json", {
socketNotificationReceived: function (notification, payload) {
if (
notification === "MMM_JSON_GET_RESPONSE" &&
payload.identifier == this.identifier
payload.identifier === this.identifier
) {
if (payload.error === true) {
console.error(
Expand Down
41 changes: 41 additions & 0 deletions MMM-json.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint no-multi-spaces: 0 */
const expect = require("chai").expect;

let modulename = "MMM-json";

xdescribe("Functions module MMM-json", function () {
before(function () {
Module = {};
config = {};
Module.definitions = {};
Module.register = function (name, moduleDefinition) {
Module.definitions[name] = moduleDefinition;
};
require("./MMM-json");
Module.definitions[modulename].config = {};
});

describe("getHeader", function () {
describe("with header icon", function () {
before(function () {
Module.definitions[modulename].config.headerIcon = "icon";
});

it(`should be empty`, function () {
expect(Module.definitions[modulename].getHeader()).to.equal("");
});
});

describe("without header icon", function () {
before(function () {
Module.definitions[modulename].data.header = "I am a Header";
});

it(`should contain header`, function () {
expect(Module.definitions[modulename].getHeader()).to.equal(
"I am a Header"
);
});
});
});
});
Loading

0 comments on commit ed4eccc

Please sign in to comment.