-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f356589
commit eddd285
Showing
51 changed files
with
2,039 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as Gooey from "../../index"; | ||
|
||
/** | ||
* @example | ||
* { | ||
* body: { | ||
* inputImage: "input_image" | ||
* } | ||
* } | ||
*/ | ||
export interface AiPhotoEditorAsyncRequest { | ||
exampleId?: string; | ||
body: Gooey.Img2ImgPageRequest; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/api/client/requests/CompareAiImageGeneratorsAsyncRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as Gooey from "../../index"; | ||
|
||
/** | ||
* @example | ||
* { | ||
* body: { | ||
* inputImage: "input_image" | ||
* } | ||
* } | ||
*/ | ||
export interface CompareAiImageGeneratorsAsyncRequest { | ||
exampleId?: string; | ||
body: Gooey.Img2ImgPageRequest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { BasicAuth } from "../../../src/core/auth/BasicAuth"; | ||
|
||
describe("BasicAuth", () => { | ||
describe("toAuthorizationHeader", () => { | ||
it("correctly converts to header", () => { | ||
expect( | ||
BasicAuth.toAuthorizationHeader({ | ||
username: "username", | ||
password: "password", | ||
}) | ||
).toBe("Basic dXNlcm5hbWU6cGFzc3dvcmQ="); | ||
}); | ||
}); | ||
describe("fromAuthorizationHeader", () => { | ||
it("correctly parses header", () => { | ||
expect(BasicAuth.fromAuthorizationHeader("Basic dXNlcm5hbWU6cGFzc3dvcmQ=")).toEqual({ | ||
username: "username", | ||
password: "password", | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BearerToken } from "../../../src/core/auth/BearerToken"; | ||
|
||
describe("BearerToken", () => { | ||
describe("toAuthorizationHeader", () => { | ||
it("correctly converts to header", () => { | ||
expect(BearerToken.toAuthorizationHeader("my-token")).toBe("Bearer my-token"); | ||
}); | ||
}); | ||
describe("fromAuthorizationHeader", () => { | ||
it("correctly parses header", () => { | ||
expect(BearerToken.fromAuthorizationHeader("Bearer my-token")).toBe("my-token"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Fetcher, fetcherImpl } from "../../../src/core/fetcher/Fetcher"; | ||
|
||
describe("Test fetcherImpl", () => { | ||
let mockCreateUrl: jest.Mock; | ||
let mockGetBody: jest.Mock; | ||
let mockGetFetchFn: jest.Mock; | ||
let mockRequestWithRetries: jest.Mock; | ||
let mockGetResponseBody: jest.Mock; | ||
|
||
beforeEach(() => { | ||
mockCreateUrl = jest.fn(); | ||
mockGetBody = jest.fn(); | ||
mockGetFetchFn = jest.fn(); | ||
mockRequestWithRetries = jest.fn(); | ||
mockGetResponseBody = jest.fn(); | ||
|
||
jest.mock("../../../src/core/fetcher/Fetcher", () => ({ | ||
createUrl: mockCreateUrl, | ||
getBody: mockGetBody, | ||
getFetchFn: mockGetFetchFn, | ||
requestWithRetries: mockRequestWithRetries, | ||
getResponseBody: mockGetResponseBody, | ||
})); | ||
}); | ||
|
||
it("should handle successful request", async () => { | ||
const mockArgs: Fetcher.Args = { | ||
url: "https://httpbin.org/post", | ||
method: "POST", | ||
headers: { "X-Test": "x-test-header" }, | ||
body: { data: "test" }, | ||
contentType: "application/json", | ||
requestType: "json", | ||
}; | ||
|
||
mockCreateUrl.mockReturnValue("https://test.com"); | ||
mockGetBody.mockResolvedValue(JSON.stringify({ data: "test" })); | ||
mockGetFetchFn.mockResolvedValue(() => Promise.resolve()); | ||
mockRequestWithRetries.mockResolvedValue({ status: 200 }); | ||
mockGetResponseBody.mockResolvedValue({ result: "success" }); | ||
|
||
const result = await fetcherImpl(mockArgs); | ||
expect(result.ok).toBe(true); | ||
// @ts-expect-error | ||
expect(result.body.json).toEqual({ data: "test" }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { createRequestUrl } from "../../../src/core/fetcher/createRequestUrl"; | ||
|
||
describe("Test createRequestUrl", () => { | ||
it("should return the base URL when no query parameters are provided", () => { | ||
const baseUrl = "https://api.example.com"; | ||
expect(createRequestUrl(baseUrl)).toBe(baseUrl); | ||
}); | ||
|
||
it("should append simple query parameters", () => { | ||
const baseUrl = "https://api.example.com"; | ||
const queryParams = { key: "value", another: "param" }; | ||
expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?key=value&another=param"); | ||
}); | ||
|
||
it("should handle array query parameters", () => { | ||
const baseUrl = "https://api.example.com"; | ||
const queryParams = { items: ["a", "b", "c"] }; | ||
expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?items=a&items=b&items=c"); | ||
}); | ||
|
||
it("should handle object query parameters", () => { | ||
const baseUrl = "https://api.example.com"; | ||
const queryParams = { filter: { name: "John", age: 30 } }; | ||
expect(createRequestUrl(baseUrl, queryParams)).toBe( | ||
"https://api.example.com?filter%5Bname%5D=John&filter%5Bage%5D=30" | ||
); | ||
}); | ||
|
||
it("should handle mixed types of query parameters", () => { | ||
const baseUrl = "https://api.example.com"; | ||
const queryParams = { | ||
simple: "value", | ||
array: ["x", "y"], | ||
object: { key: "value" }, | ||
}; | ||
expect(createRequestUrl(baseUrl, queryParams)).toBe( | ||
"https://api.example.com?simple=value&array=x&array=y&object%5Bkey%5D=value" | ||
); | ||
}); | ||
|
||
it("should handle empty query parameters object", () => { | ||
const baseUrl = "https://api.example.com"; | ||
expect(createRequestUrl(baseUrl, {})).toBe(baseUrl); | ||
}); | ||
|
||
it("should encode special characters in query parameters", () => { | ||
const baseUrl = "https://api.example.com"; | ||
const queryParams = { special: "a&b=c d" }; | ||
expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?special=a%26b%3Dc%20d"); | ||
}); | ||
}); |
Oops, something went wrong.