-
-
Notifications
You must be signed in to change notification settings - Fork 186
test: server utils #27
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
test: server utils #27
Conversation
|
@devdumpling is attempting to deploy a commit to the danielroe Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops ignore this change, will pull it out--meant to only keep it in this PR: #26
will pull it shortly
| const mockFetchOk = <T>(body: T) => { | ||
| const fetchMock = vi.fn().mockResolvedValue({ | ||
| ok: true, | ||
| json: async () => body, | ||
| }) | ||
| vi.stubGlobal('fetch', fetchMock) | ||
| return fetchMock | ||
| } | ||
|
|
||
| const mockFetchError = (status: number) => { | ||
| const fetchMock = vi.fn().mockResolvedValue({ | ||
| ok: false, | ||
| status, | ||
| }) | ||
| vi.stubGlobal('fetch', fetchMock) | ||
| return fetchMock | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could move these out for re-use but haven't looked at all the testing patterns in place yet in full
|
|
||
| describe('convertToFileTree', () => { | ||
| it('converts jsDelivr nodes to a sorted tree with directories first', () => { | ||
| const input: JsDelivrFileNode[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super familiar with jsDeliver. LMK if this is too rudimentary.
|
this is great - thank you! ❤️ |
Overview
Wanted to get a better understanding of the repo so started trying to add some tests. Looks like these server utils were a bit underserved and relatively pure / understandable. Let me know if you have any questions / thoughts.