|
1 | 1 | importdayjsfrom"dayjs"
|
2 | 2 | import*asTypesGenfrom"../api/typesGenerated"
|
3 | 3 | import*asMocksfrom"../testHelpers/entities"
|
4 |
| -import{defaultWorkspaceExtension,isWorkspaceOn,workspaceQueryToFilter}from"./workspace" |
| 4 | +import{defaultWorkspaceExtension,isWorkspaceDeleted,isWorkspaceOn,workspaceQueryToFilter}from"./workspace" |
5 | 5 |
|
6 | 6 | describe("util > workspace",()=>{
|
7 | 7 | describe("isWorkspaceOn",()=>{
|
@@ -42,6 +42,44 @@ describe("util > workspace", () => {
|
42 | 42 | })
|
43 | 43 | })
|
44 | 44 |
|
| 45 | +describe("isWorkspaceDeleted",()=>{ |
| 46 | +it.each<[TypesGen.WorkspaceTransition,TypesGen.ProvisionerJobStatus,boolean]>([ |
| 47 | +["delete","canceled",false], |
| 48 | +["delete","canceling",false], |
| 49 | +["delete","failed",false], |
| 50 | +["delete","pending",false], |
| 51 | +["delete","running",false], |
| 52 | +["delete","succeeded",true], |
| 53 | + |
| 54 | +["stop","canceled",false], |
| 55 | +["stop","canceling",false], |
| 56 | +["stop","failed",false], |
| 57 | +["stop","pending",false], |
| 58 | +["stop","running",false], |
| 59 | +["stop","succeeded",false], |
| 60 | + |
| 61 | +["start","canceled",false], |
| 62 | +["start","canceling",false], |
| 63 | +["start","failed",false], |
| 64 | +["start","pending",false], |
| 65 | +["start","running",false], |
| 66 | +["start","succeeded",false], |
| 67 | +])(`transition=%p, status=%p, isWorkspaceDeleted=%p`,(transition,status,isDeleted)=>{ |
| 68 | +constworkspace:TypesGen.Workspace={ |
| 69 | + ...Mocks.MockWorkspace, |
| 70 | +latest_build:{ |
| 71 | + ...Mocks.MockWorkspaceBuild, |
| 72 | +job:{ |
| 73 | + ...Mocks.MockProvisionerJob, |
| 74 | + status, |
| 75 | +}, |
| 76 | + transition, |
| 77 | +}, |
| 78 | +} |
| 79 | +expect(isWorkspaceDeleted(workspace)).toBe(isDeleted) |
| 80 | +}) |
| 81 | +}) |
| 82 | + |
45 | 83 | describe("defaultWorkspaceExtension",()=>{
|
46 | 84 | it.each<[string,TypesGen.PutExtendWorkspaceRequest]>([
|
47 | 85 | [
|
|