Skip to content

Commit f3bffb1

Browse files
committed
test: tag 가 없는 상황일때 테스트 케이스 추가
1 parent ff37785 commit f3bffb1

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

packages/patchlogr-core/src/partition/__tests__/partitionByTag.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CanonicalSpec } from "@patchlogr/types";
22
import { describe, expect, test } from "vitest";
3-
import { partitionByTag } from "../partitionByTag";
3+
import { DEFAULT_TAG, partitionByTag } from "../partitionByTag";
44

55
describe("partitionByTag", () => {
66
test("should group by first tag", () => {
@@ -66,4 +66,27 @@ describe("partitionByTag", () => {
6666
"POST /auth/login",
6767
);
6868
});
69+
70+
test("should group into default tag if tag not exists", () => {
71+
const spec: CanonicalSpec = {
72+
operations: {
73+
"GET /user": {
74+
key: "GET /user",
75+
doc: { tags: [] },
76+
method: "GET",
77+
path: "/user",
78+
request: { params: [] },
79+
responses: {},
80+
},
81+
},
82+
};
83+
84+
const partitions = partitionByTag(spec).partitions;
85+
86+
expect(partitions).toHaveLength(1);
87+
expect(partitions.get(DEFAULT_TAG)).toHaveLength(1);
88+
expect(partitions.get(DEFAULT_TAG)?.[0]?.operationKey).toBe(
89+
"GET /user",
90+
);
91+
});
6992
});

packages/patchlogr-core/src/partition/partitionByTag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Partition, PartitionedSpec } from "./partition";
44
import { createSHA256Hash } from "../utils/createHash";
55
import { stableStringify } from "../utils/stableStringify";
66

7-
const DEFAULT_TAG = "__DEFAULT__";
7+
export const DEFAULT_TAG = "__DEFAULT__";
88

99
export function partitionByTag(spec: CanonicalSpec): PartitionedSpec {
1010
const partitions = new Map<string, Partition[]>();

0 commit comments

Comments
 (0)