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

add test for support for optional formData #123

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

kainpets
Copy link
Contributor

@kainpets kainpets commented Nov 6, 2023

No description provided.

@kainpets kainpets linked an issue Nov 6, 2023 that may be closed by this pull request
@kainpets kainpets marked this pull request as ready for review November 6, 2023 21:01
@kainpets kainpets marked this pull request as draft November 7, 2023 02:26
@kainpets kainpets force-pushed the support-zod-optional-formData branch from 5a87b62 to a5eb057 Compare November 13, 2023 13:57
@kainpets kainpets changed the title initial commit add support for optional formData Nov 13, 2023
@@ -23,3 +24,28 @@ test("POST /todo/form-add", async (t) => {

t.is(successfulRes.status, 200)
})

test("Valid formData object passes validation", (t) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to actually call and endpoint

@kainpets kainpets requested a review from itelo November 13, 2023 22:51

axios.defaults.headers.common.Authorization = `Bearer auth_token`

const bodyFormData = new URLSearchParams()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const bodyFormData = new URLSearchParams()
const bodyFormData = new FormData()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like FormData isn't supported. Seve created an issue to implement support for that: #127

@kainpets kainpets requested a review from itelo November 14, 2023 20:55
@kainpets kainpets marked this pull request as ready for review November 16, 2023 12:59
@seveibar seveibar changed the title add support for optional formData add test for support for optional formData Dec 7, 2023

const validFormData = {
title: "test title",
clear_sandbox_state: "clear_sandbox_state",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clear_sandbox_state: "clear_sandbox_state",
completed: true,

Comment on lines 49 to 56
const formDataSchema = z
.object({
title: z.string(),
clear_sandbox_state: z.literal("clear_sandbox_state"),
})
.safeParse(validFormData)

t.true(formDataSchema.success)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const formDataSchema = z
.object({
title: z.string(),
clear_sandbox_state: z.literal("clear_sandbox_state"),
})
.safeParse(validFormData)
t.true(formDataSchema.success)

@kainpets kainpets marked this pull request as draft December 15, 2023 19:24
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

Successfully merging this pull request may close these issues.

Nextlove should support .optional() on formData
3 participants