Merge pull request #18093 from timvandermeij/exception
Implement a unit test for the `BaseException` class
This commit is contained in:
commit
66c2bf62c1
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
BaseException,
|
||||||
bytesToString,
|
bytesToString,
|
||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
getModificationDate,
|
getModificationDate,
|
||||||
@ -23,6 +24,25 @@ import {
|
|||||||
} from "../../src/shared/util.js";
|
} from "../../src/shared/util.js";
|
||||||
|
|
||||||
describe("util", function () {
|
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 () {
|
describe("bytesToString", function () {
|
||||||
it("handles non-array arguments", function () {
|
it("handles non-array arguments", function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user