-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
7 changed files
with
127 additions
and
157 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
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 |
---|---|---|
@@ -1,54 +1,46 @@ | ||
import { buildMapper } from "../../src/utils/helpers"; | ||
import { buildDatetimeStatus } from "../../src/utils/helpers"; | ||
import { BUILD } from "../testutils"; | ||
|
||
const generateBuild = (status: string) => [ | ||
{ | ||
...BUILD, | ||
status | ||
} | ||
]; | ||
describe("buildMapper", () => { | ||
const generateBuild = (status: string) => ({ | ||
...BUILD, | ||
status | ||
}); | ||
|
||
describe("buildDatetimeStatus", () => { | ||
it("should return an active build", () => { | ||
const builds = generateBuild("COMPLETED"); | ||
const [mappedBuild] = buildMapper(builds, 1); | ||
expect(mappedBuild.name).toContain("Active"); | ||
const build = generateBuild("COMPLETED"); | ||
expect(buildDatetimeStatus(build, 1)).toMatch(/Active$/); | ||
}); | ||
|
||
it("should return build", () => { | ||
const builds = generateBuild("BUILDING"); | ||
const [mappedBuild] = buildMapper(builds, 2); | ||
expect(mappedBuild.name).toContain("Building"); | ||
const build = generateBuild("BUILDING"); | ||
expect(buildDatetimeStatus(build, 2)).toMatch(/Building$/); | ||
}); | ||
|
||
it("should return queued build", () => { | ||
const builds = generateBuild("QUEUED"); | ||
const [mappedBuild] = buildMapper(builds, 2); | ||
expect(mappedBuild.name).toContain("Queued"); | ||
const build = generateBuild("QUEUED"); | ||
expect(buildDatetimeStatus(build, 2)).toMatch(/Queued$/); | ||
}); | ||
|
||
it("should return completed build", () => { | ||
const builds = generateBuild("COMPLETED"); | ||
const [mappedBuild] = buildMapper(builds, 2); | ||
expect(mappedBuild.name).toContain("Available"); | ||
const build = generateBuild("COMPLETED"); | ||
expect(buildDatetimeStatus(build, 2)).toMatch(/Available$/); | ||
}); | ||
|
||
it("should return failed build", () => { | ||
const builds = generateBuild("FAILED"); | ||
const [mappedBuild] = buildMapper(builds, 2); | ||
expect(mappedBuild.name).toContain("Failed"); | ||
const build = generateBuild("FAILED"); | ||
expect(buildDatetimeStatus(build, 2)).toMatch(/Failed$/); | ||
}); | ||
|
||
it("should use the scheduled_on date if the ended_on prop is null", () => { | ||
const [mappedBuild] = buildMapper( | ||
[ | ||
{ | ||
...BUILD, | ||
status: "FAILED", | ||
ended_on: null | ||
} | ||
], | ||
const datetimeStatus = buildDatetimeStatus( | ||
{ | ||
...BUILD, | ||
status: "FAILED", | ||
ended_on: null | ||
}, | ||
2 | ||
); | ||
expect(mappedBuild.name).toContain("November 8th, 2022"); | ||
expect(datetimeStatus).toContain("November 8th, 2022"); | ||
}); | ||
}); |
Oops, something went wrong.