Skip to content

Commit

Permalink
fix: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Apr 10, 2020
1 parent abdf249 commit 7d70bcd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/electrode-react-webapp/lib/render-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Output {
out += x.stringify();
} else {
const typeName = (x && x.constructor && x.constructor.name) || typeof x;
const msg = `SpotOutput unable to stringify item of type ${typeName}`;
const msg = `RenderOutput unable to stringify item of type ${typeName}`;
console.error("FATAL Error:", msg + "\n"); // eslint-disable-line
throw new Error(msg);
}
Expand Down
14 changes: 14 additions & 0 deletions packages/electrode-react-webapp/test/spec/render-output.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,18 @@ describe("render-output", function() {
};
expect(() => ro._finish()).to.throw("test error");
});

it("should throw if can't stringify an item", () => {
const ro = new RenderOutput();
ro.add({});
expect(() => ro.flush()).to.throw("unable to stringify item of type Object");
});

it("should throw if can't stringify an item without constructor", () => {
const ro = new RenderOutput();
const item = {};
item.constructor = false;
ro.add(item);
expect(() => ro.flush()).to.throw("unable to stringify item of type object");
});
});
2 changes: 1 addition & 1 deletion packages/subapp-web/lib/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

/* eslint-disable global-require, max-statements, no-loop-func */
/* eslint-disable global-require, max-statements, no-loop-func, max-len */

const Fs = require("fs");
const assert = require("assert");
Expand Down

0 comments on commit 7d70bcd

Please sign in to comment.