Skip to content

Commit

Permalink
Merge pull request #18093 from timvandermeij/exception
Browse files Browse the repository at this point in the history
Implement a unit test for the `BaseException` class
  • Loading branch information
timvandermeij committed May 15, 2024
2 parents 7e5e06b + 6b237e3 commit 66c2bf6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/unit/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

import {
BaseException,
bytesToString,
createValidAbsoluteUrl,
getModificationDate,
Expand All @@ -23,6 +24,25 @@ import {
} from "../../src/shared/util.js";

describe("util", function () {
describe("BaseException", function () {
it("can initialize exception classes derived from BaseException", function () {
class DerivedException extends BaseException {
constructor(message) {
super(message, "DerivedException");
this.foo = "bar";
}
}

const exception = new DerivedException("Something went wrong");
expect(exception instanceof DerivedException).toEqual(true);
expect(exception instanceof BaseException).toEqual(true);
expect(exception.message).toEqual("Something went wrong");
expect(exception.name).toEqual("DerivedException");
expect(exception.foo).toEqual("bar");
expect(exception.stack).toContain("BaseExceptionClosure");
});
});

describe("bytesToString", function () {
it("handles non-array arguments", function () {
expect(function () {
Expand Down

0 comments on commit 66c2bf6

Please sign in to comment.