Skip to content

Commit

Permalink
feat(view): Commit 타입에 tag와 releaseTag가 추가됨에 따라 관련 테스트 코드 추가(githru#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakseong committed Oct 6, 2024
1 parent 4d53563 commit 449b66d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 22 deletions.
18 changes: 12 additions & 6 deletions packages/view/src/components/Detail/Detail.util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const fakeCommitNodeListInCluster: CommitNode[] = [
},
},
message: "feat(webview): add typescript structure",
tags: [],
releaseTags: [],
tags: ["v1.1.0"],
releaseTags: ["v1.1.0"],
},
seq: 0,
clusterId: 4,
Expand Down Expand Up @@ -125,8 +125,8 @@ const fakeCommitNodeListInCluster: CommitNode[] = [
},
},
message: "feat(vscode): launch webview for webviewApp",
tags: [],
releaseTags: [],
tags: ["v1.2.0", "v1.3.0"],
releaseTags: ["v1.2.0", "v1.3.0"],
},
clusterId: 4,
seq: 1,
Expand Down Expand Up @@ -200,8 +200,8 @@ const fakeCommitNodeListInCluster: CommitNode[] = [
},
},
message: "setup(vscode): add webview loader",
tags: [],
releaseTags: [],
tags: ["v1.4.0", "v1.5.0"],
releaseTags: ["v1.4.0"],
},
seq: 2,
clusterId: 4,
Expand All @@ -227,6 +227,12 @@ test("getSummaryCommitList test", () => {
expect(result1).not.toBeUndefined();
expect(result1).toHaveLength(3);
expect(result1[0].commit.id).toBe(fakeCommitNodeListInCluster[0].commit.id);
expect(result1[0].commit.tags).toBe(fakeCommitNodeListInCluster[0].commit.tags);
expect(result1[0].commit.releaseTags).toBe(fakeCommitNodeListInCluster[0].commit.releaseTags);
expect(result1[1].commit.id).toBe(fakeCommitNodeListInCluster[1].commit.id);
expect(result1[1].commit.tags).toBe(fakeCommitNodeListInCluster[1].commit.tags);
expect(result1[1].commit.releaseTags).toBe(fakeCommitNodeListInCluster[1].commit.releaseTags);
expect(result1[2].commit.id).toBe(fakeCommitNodeListInCluster[2].commit.id);
expect(result1[2].commit.tags).toBe(fakeCommitNodeListInCluster[2].commit.tags);
expect(result1[2].commit.releaseTags).toBe(fakeCommitNodeListInCluster[2].commit.releaseTags);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ClusterNode } from "types";

import { getClusterById, getClusterIds, getInitData } from "./Summary.util";
import { getClusterById, getClusterIds, getInitData, getCommitLatestTag } from "./Summary.util";

const clusterNodeMockData: ClusterNode[] = [
{
Expand All @@ -20,8 +20,52 @@ const clusterNodeMockData: ClusterNode[] = [
},
id: "71627b0568035fcf923e18a36b4f3f09fc1632c5",
message: "Initial commit",
tags: [],
releaseTags: [],
tags: ["v1.1.0", "v1.1.1"],
releaseTags: ["v1.1.1"],
parentIds: [],
},
nodeTypeName: "COMMIT",
seq: 1,
},
{
clusterId: 1,
commit: {
author: { id: "no-id", emails: ["[email protected]"], names: ["ytaek"] },
authorDate: "Thu Apr 28 2022 01:19:50 GMT+0900 (Korean Standard Time)",
commitDate: "Thu Apr 28 2022 01:19:50 GMT+0900 (Korean Standard Time)",
committer: { emails: ["[email protected]"], id: "no-id", names: ["GitHub"] },
diffStatistics: {
changedFileCount: 2,
deletions: 0,
insertions: 203,
files: { LICENSE: { insertions: 201, deletions: 0 }, "README.md": { insertions: 2, deletions: 0 } },
},
id: "71627b0568035fcf923e18a36b4f3f09fc1632c5",
message: "Initial commit",
tags: ["v1.1.1", "v1.1.2"],
releaseTags: ["v1.1.1", "v1.1.2"],
parentIds: [],
},
nodeTypeName: "COMMIT",
seq: 1,
},
{
clusterId: 2,
commit: {
author: { id: "no-id", emails: ["[email protected]"], names: ["ytaek"] },
authorDate: "Thu Apr 28 2022 01:19:50 GMT+0900 (Korean Standard Time)",
commitDate: "Thu Apr 28 2022 01:19:50 GMT+0900 (Korean Standard Time)",
committer: { emails: ["[email protected]"], id: "no-id", names: ["GitHub"] },
diffStatistics: {
changedFileCount: 2,
deletions: 0,
insertions: 203,
files: { LICENSE: { insertions: 201, deletions: 0 }, "README.md": { insertions: 2, deletions: 0 } },
},
id: "71627b0568035fcf923e18a36b4f3f09fc1632c5",
message: "Initial commit",
tags: ["v1.1.3"],
releaseTags: ["v1.1.3", "v1.1.4"],
parentIds: [],
},
nodeTypeName: "COMMIT",
Expand All @@ -33,7 +77,7 @@ const clusterNodeMockData: ClusterNode[] = [
{
commitNodeList: [
{
clusterId: 1,
clusterId: 3,
commit: {
author: { id: "no-id", emails: ["[email protected]"], names: ["ytaek"] },
authorDate: "Thu Apr 28 2022 01:19:50 GMT+0900 (Korean Standard Time)",
Expand Down Expand Up @@ -80,7 +124,7 @@ test("getClusterIds test", () => {

expect(result).not.toBeUndefined();
expect(result[0]).toBe(0);
expect(result[1]).toBe(1);
expect(result[1]).toBe(3);
expect(result).toHaveLength(2);
});

Expand All @@ -91,4 +135,13 @@ test("getInitData test", () => {
expect(result[0].clusterId).toBe(0);
expect(result[0].summary.authorNames[0][0]).toBe("ytaek");
expect(result[0].summary.content.message).toBe("Initial commit");
expect(result[0].clusterTags).toEqual(["v1.1.1", "v1.1.2", "v1.1.3", "v1.1.4"]);
expect(result[0].clusterTags).toHaveLength(4);
});

test("getCommitLatestTag test", () => {
const clusters = getInitData(clusterNodeMockData);
const result = getCommitLatestTag(clusters[0].clusterTags);

expect(result).toBe("v1.1.4");
});
28 changes: 17 additions & 11 deletions packages/view/src/fake-assets/cluster-nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10602,7 +10602,9 @@
}
}
},
"message": "feat: add contributing md and readme md files (#160)"
"message": "feat: add contributing md and readme md files (#160)",
"tags": ["v1.0.0", "v1.1.0"],
"releaseTags": ["v1.0.0", "v1.1.0"]
},
"clusterId": 90
}
Expand Down Expand Up @@ -10647,9 +10649,7 @@
}
}
},
"message": "Merge pull request #159 from vgihan/main/n/nfix(view): modify variable height ClusterGraph transition & update scroll",
"tags": ["v1.1.0"],
"releaseTags": ["v1.1.0"]
"message": "Merge pull request #159 from vgihan/main/n/nfix(view): modify variable height ClusterGraph transition & update scroll"
},
"clusterId": 91
},
Expand Down Expand Up @@ -10721,7 +10721,9 @@
}
}
},
"message": "fix(view): update style problem in VerticalClusterList"
"message": "fix(view): update style problem in VerticalClusterList",
"tags": ["v1.2.0"],
"releaseTags": ["v1.2.0"]
},
"clusterId": 91
},
Expand Down Expand Up @@ -10753,7 +10755,9 @@
}
}
},
"message": "fix(view): add ClusterGraph useEffect deps"
"message": "fix(view): add ClusterGraph useEffect deps",
"tags": ["v1.1.0"],
"releaseTags": ["v1.1.0"]
},
"clusterId": 91
},
Expand Down Expand Up @@ -10785,7 +10789,9 @@
}
}
},
"message": "feat(view): add scroll center in Summary"
"message": "feat(view): add scroll center in Summary",
"tags": ["v1.1.0"],
"releaseTags": ["v1.1.0"]
},
"clusterId": 91
},
Expand Down Expand Up @@ -10826,8 +10832,8 @@
}
},
"message": "fix(view): modify variable height detail problem",
"tags": ["v1.2.0"],
"releaseTags": ["v1.2.0"]
"tags": ["v1.3.0"],
"releaseTags": ["v1.3.0"]
},
"clusterId": 91
}
Expand Down Expand Up @@ -10943,8 +10949,8 @@
}
},
"message": "style(view): fit summary height and delete animation (#163)",
"tags": ["v1.3.0"],
"releaseTags": ["v1.3.0"]
"tags": ["v1.4.0"],
"releaseTags": ["v1.4.0"]
},
"clusterId": 94
}
Expand Down

0 comments on commit 449b66d

Please sign in to comment.