Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test codegen #233

Open
david-crespo opened this issue Mar 19, 2024 · 0 comments
Open

Unit test codegen #233

david-crespo opened this issue Mar 19, 2024 · 0 comments

Comments

@david-crespo
Copy link
Collaborator

#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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant