mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
test: prune redundant and implementation-coupled coverage
This commit is contained in:
1 parent
14b15ba8a5
commit
48e27e19b7
191 files changed
+2757
-5418
No files matched your search
@@ -11,8 +11,15 @@ type JsonValue =
|
||||
| { [key: string]: JsonValue };
|
||||
|
||||
it("accepts non-null objects other than arrays", () => {
|
||||
expect(isRecord({})).toBe(true);
|
||||
expect(isRecord(Object.create(null))).toBe(true);
|
||||
const json: JsonValue = JSON.parse('{"a":1}');
|
||||
if (!isRecord(json)) throw new Error("Expected a JSON object");
|
||||
expect(json.a).toBe(1);
|
||||
expectTypeOf(json.a).toEqualTypeOf<JsonValue | undefined>();
|
||||
|
||||
const withoutPrototype: unknown = Object.create(null);
|
||||
if (!isRecord(withoutPrototype))
|
||||
throw new Error("Expected an object without a prototype");
|
||||
expectTypeOf(withoutPrototype).toEqualTypeOf<Record<string, unknown>>();
|
||||
expect(isRecord(new Error("x"))).toBe(true);
|
||||
expect(isRecord([])).toBe(false);
|
||||
expect(isRecord(null)).toBe(false);
|
||||
@@ -20,12 +27,3 @@ it("accepts non-null objects other than arrays", () => {
|
||||
expect(isRecord("text")).toBe(false);
|
||||
expect(isRecord(() => undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("narrows a JSON value to its object member and unknown to a string-keyed record", () => {
|
||||
const json = JSON.parse('{"a":1}') as JsonValue;
|
||||
if (isRecord(json))
|
||||
expectTypeOf(json.a).toEqualTypeOf<JsonValue | undefined>();
|
||||
const value: unknown = json;
|
||||
if (isRecord(value))
|
||||
expectTypeOf(value).toEqualTypeOf<Record<string, unknown>>();
|
||||
});
|
||||
Reference in new issue
Block a user