Fixes #529 Add zip and tarball urls to output

This commit is contained in:
Nick Cipollo
2025-06-28 21:23:15 -04:00
parent 0683ea3557
commit 7922049688
11 changed files with 933 additions and 827 deletions

View File

@@ -7,6 +7,13 @@ jest.mock("@actions/core", () => {
return { setOutput: mockSetOutput }
})
const TEST_URLS = {
HTML_URL: "https://api.example.com/assets",
UPLOAD_URL: "https://api.example.com",
TARBALL_URL: "https://api.example.com/tarball",
ZIPBALL_URL: "https://api.example.com/zipball",
} as const
describe("Outputs", () => {
let outputs: Outputs
let releaseData: ReleaseData
@@ -15,15 +22,30 @@ describe("Outputs", () => {
outputs = new CoreOutputs()
releaseData = {
id: 1,
html_url: "https://api.example.com/assets",
upload_url: "https://api.example.com",
html_url: TEST_URLS.HTML_URL,
upload_url: TEST_URLS.UPLOAD_URL,
tarball_url: TEST_URLS.TARBALL_URL,
zipball_url: TEST_URLS.ZIPBALL_URL,
}
})
it("Applies the release data to the action output", () => {
outputs.applyReleaseData(releaseData)
expect(mockSetOutput).toBeCalledWith("id", releaseData.id)
expect(mockSetOutput).toBeCalledWith("html_url", releaseData.html_url)
expect(mockSetOutput).toBeCalledWith("upload_url", releaseData.upload_url)
expect(mockSetOutput).toHaveBeenCalledWith("id", releaseData.id)
expect(mockSetOutput).toHaveBeenCalledWith("html_url", releaseData.html_url)
expect(mockSetOutput).toHaveBeenCalledWith("upload_url", releaseData.upload_url)
expect(mockSetOutput).toHaveBeenCalledWith("tarball_url", releaseData.tarball_url)
expect(mockSetOutput).toHaveBeenCalledWith("zipball_url", releaseData.zipball_url)
})
it("Handles null tarball_url and zipball_url", () => {
const releaseDataWithNulls = {
...releaseData,
tarball_url: null,
zipball_url: null,
}
outputs.applyReleaseData(releaseDataWithNulls)
expect(mockSetOutput).toHaveBeenCalledWith("tarball_url", "")
expect(mockSetOutput).toHaveBeenCalledWith("zipball_url", "")
})
})