Fixes #1 Allow for multiple artifacts

This commit is contained in:
Nick Cipollo
2019-09-02 17:20:04 -04:00
parent 261c1fc08b
commit a698287254
24 changed files with 462 additions and 167 deletions

View File

@@ -0,0 +1,39 @@
import { FileArtifactGlobber } from "../src/ArtifactGlobber"
import { Globber } from "../src/Globber";
import { Artifact } from "../src/Artifact";
const contentType = "raw"
const globResults = ["file1", "file2"]
describe("ArtifactGlobber", () => {
it("globs simple path", () => {
const globber = createArtifactGlobber()
const expectedArtifacts =
globResults.map((path) => new Artifact(path, contentType))
expect(globber.globArtifactString('path', 'raw'))
.toEqual(expectedArtifacts)
})
it("splits multiple paths", () => {
const globber = createArtifactGlobber()
const expectedArtifacts =
globResults
.concat(globResults)
.map((path) => new Artifact(path, contentType))
expect(globber.globArtifactString('path1,path2', 'raw'))
.toEqual(expectedArtifacts)
})
function createArtifactGlobber(): FileArtifactGlobber {
const MockGlobber = jest.fn<Globber, any>(() => {
return {
glob: () => globResults
}
})
return new FileArtifactGlobber(new MockGlobber())
}
})