Skip to content

Unit test codegen #233

@david-crespo

Description

@david-crespo

#231 is in the trash, but it had one part I really liked, and can't believe we didn't do before: pure functions that take in a chunk of schema and assert on the generated code!

describe("generateTransformFunction", () => {
it("handles timestamps at top level", () => {
expect(genTransformResponse(projectSchema)).toMatchInlineSnapshot(`
"(o) => {
o.time_created = new Date(o.time_created)
o.time_modified = new Date(o.time_modified)
}"
`);
});
it("returns null when there are no transforms to make", () => {
expect(genTransformResponse(noTransforms)).toEqual(undefined);
});
});

I also learned about these libraries that could give more structure to our very stringy generation code:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions