Files
release-action/__tests__/Artifact.test.ts
Nick Cipollo 6c75be85e5
Some checks failed
Test / check_pr (push) Has been cancelled
Fixes #357 Use a read stream for artifacts.
This seems to be safe since octokit mentions ReadableStreams in their fetcher wrapper & tests: https://github.com/octokit/request.js/blob/main/src/fetch-wrapper.ts#L44
(and also it seems to work when I test it).
2023-08-24 08:37:01 -04:00

40 lines
1.0 KiB
TypeScript

import {Artifact} from "../src/Artifact";
const contentLength = 42
const fakeReadStream = {}
jest.mock('fs', () => {
return {
createReadStream: () => fakeReadStream,
statSync: () => {
return {size: contentLength}
}
};
})
describe("Artifact", () => {
it('defaults contentType to raw', () => {
const artifact = new Artifact('')
expect(artifact.contentType).toBe('raw')
})
it('generates name from path', () => {
const artifact = new Artifact('some/artifact')
expect(artifact.name).toBe('artifact')
})
it('provides contentLength', () => {
const artifact = new Artifact('some/artifact')
expect(artifact.contentLength).toBe(contentLength)
})
it('provides path', () => {
const artifact = new Artifact('some/artifact')
expect(artifact.path).toBe('some/artifact')
})
it('reads artifact', () => {
const artifact = new Artifact('some/artifact')
expect(artifact.readFile()).toBe(fakeReadStream)
})
})