Skip to content

Commit cf5d43d

Browse files
thomasballingerConvex, Inc.
authored and
Convex, Inc.
committed
Test that system fields are not exposed in table validators (#27195)
Test that system fields are not exposed in table validators. This is not a behavior change, just making the tests clearer. GitOrigin-RevId: 363b0b6f224fd36ef40d8955614d3bd1fe81c4a7
1 parent 02d07d6 commit cf5d43d

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

npm-packages/convex/src/server/schema.test.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -720,22 +720,32 @@ test("Infer", () => {
720720
assert<Equals<Actual, Expected>>();
721721
});
722722

723-
test("defineSchema exposes table validators", () => {
723+
describe("defineSchema/defineTable expose table validators", () => {
724724
const obj = {
725725
ref: v.id("reference"),
726726
string: v.string(),
727727
} as const;
728728
const table = defineTable(obj);
729-
const actual = table.validator;
730-
const expected = v.object(obj);
731-
expect(actual).toEqual(expected);
732-
assert<Equals<typeof actual, typeof expected>>();
729+
const schema = defineSchema({ table });
733730

734-
const schema = defineSchema({
735-
table: defineTable(obj),
731+
test("defineTable", () => {
732+
const actual = table.validator;
733+
const expected = v.object(obj);
734+
expect(actual).toEqual(expected);
735+
assert<Equals<typeof actual, typeof expected>>();
736+
});
737+
738+
test("defineSchema", () => {
739+
const actual = schema.tables.table.validator;
740+
const expected = v.object(obj);
741+
expect(actual).toEqual(expected);
742+
assert<Equals<typeof actual, typeof expected>>();
736743
});
737744

738-
const actual2 = schema.tables.table.validator;
739-
expect(actual2).toEqual(expected);
740-
assert<Equals<typeof actual2, typeof expected>>();
745+
test("system tables are not present", () => {
746+
expect(table.validator).not.toHaveProperty("_id");
747+
expect(table.validator).not.toHaveProperty("_creationTime");
748+
expect(schema.tables.table.validator).not.toHaveProperty("_id");
749+
expect(schema.tables.table.validator).not.toHaveProperty("_creationTime");
750+
});
741751
});

0 commit comments

Comments
 (0)