Copilot commented on code in PR #6633:
URL: https://github.com/apache/texera/pull/6633#discussion_r3617790583


##########
frontend/src/app/common/util/assert.spec.ts:
##########
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { assert, assertType, asType, isNotNull, isNull, isType, nonNull } from 
"./assert";
+
+describe("assertType", () => {
+  it("does not throw for defined values, including falsy ones", () => {
+    expect(() => assertType<number>(0)).not.toThrow();
+    expect(() => assertType<string>("")).not.toThrow();
+    expect(() => assertType<boolean>(false)).not.toThrow();
+    expect(() => assertType<object>({})).not.toThrow();
+  });
+
+  it("throws a TypeError for null", () => {
+    expect(() => assertType<number>(null)).toThrow(TypeError);
+  });
+
+  it("throws a TypeError for undefined", () => {
+    expect(() => assertType<number>(undefined)).toThrow(TypeError);
+  });
+
+  it("reports the received value in the error message", () => {
+    expect(() => assertType<number>(null)).toThrow("received null");
+    expect(() => assertType<number>(undefined)).toThrow("received undefined");
+  });
+});
+
+describe("assert", () => {
+  it("does not throw when the condition is true", () => {
+    expect(() => assert(true)).not.toThrow();
+  });
+
+  it("throws an Error when the condition is false", () => {
+    expect(() => assert(false)).toThrow(Error);
+  });
+
+  it("uses the supplied message on failure", () => {
+    expect(() => assert(false, "boom")).toThrow("boom");
+  });
+
+  it("throws with an empty message when none is provided", () => {
+    expect(() => assert(false)).toThrow();
+  });

Review Comment:
   This test claims to assert that `assert(false)` throws with an *empty* 
message when no message is provided, but it currently only checks that an error 
is thrown (which would also pass even if the error message were non-empty). 
Consider asserting `Error.message === ""` to match the test name and pin the 
current behavior of `new Error(undefined)`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to