Skip to content

Commit 59c509f

Browse files
committed
✨ 更新測試中的錯誤訊息為繁體中文
1 parent 6f2ef7a commit 59c509f

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

test/core/parsers/change-parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('ChangeParser', () => {
4444
expect(change.deltas.length).toBeGreaterThan(0);
4545
// Since delta spec exists, the description should reflect delta-derived entries
4646
expect(change.deltas[0].spec).toBe('foo');
47-
expect(change.deltas[0].description).toContain('Add requirement:');
47+
expect(change.deltas[0].description).toContain('新增需求:');
4848
expect(change.deltas[0].operation).toBe('ADDED');
4949
expect(change.deltas[0].requirement).toBeDefined();
5050
});

test/core/parsers/markdown-parser.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ When action
9090
Then result`;
9191

9292
const parser = new MarkdownParser(content);
93-
expect(() => parser.parseSpec('test')).toThrow('must have a Purpose section');
93+
expect(() => parser.parseSpec('test')).toThrow('規範必須包含目的區段');
9494
});
9595

9696
it('should throw error for missing requirements', () => {
@@ -100,7 +100,7 @@ Then result`;
100100
This is a test spec`;
101101

102102
const parser = new MarkdownParser(content);
103-
expect(() => parser.parseSpec('test')).toThrow('must have a Requirements section');
103+
expect(() => parser.parseSpec('test')).toThrow('規範必須包含需求區段');
104104
});
105105
});
106106

@@ -142,7 +142,7 @@ We need to implement user authentication to secure the application and protect u
142142
- **test:** Add test`;
143143

144144
const parser = new MarkdownParser(content);
145-
expect(() => parser.parseChange('test')).toThrow('must have a Why section');
145+
expect(() => parser.parseChange('test')).toThrow('變更必須包含為什麼區段');
146146
});
147147

148148
it('should throw error for missing what changes section', () => {
@@ -152,7 +152,7 @@ We need to implement user authentication to secure the application and protect u
152152
Because we need it`;
153153

154154
const parser = new MarkdownParser(content);
155-
expect(() => parser.parseChange('test')).toThrow('must have a What Changes section');
155+
expect(() => parser.parseChange('test')).toThrow('變更必須包含變更內容區段');
156156
});
157157

158158
it('should handle changes without deltas', () => {

test/core/validation.enriched-messages.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ There are changes proposed, but no delta specs provided yet.`;
2929
const report = await validator.validateChange(changePath);
3030
expect(report.valid).toBe(false);
3131
const msg = report.issues.map(i => i.message).join('\n');
32-
expect(msg).toContain('Change must have at least one delta');
32+
expect(msg).toContain('變更必須至少有一個差異');
3333
expect(msg).toContain('請確保您的變更有一個 specs/ 目錄');
3434
expect(msg).toContain('## ADDED/MODIFIED/REMOVED/RENAMED Requirements');
3535
});
@@ -43,8 +43,8 @@ There are changes proposed, but no delta specs provided yet.`;
4343
const report = await validator.validateSpec(specPath);
4444
expect(report.valid).toBe(false);
4545
const msg = report.issues.map(i => i.message).join('\n');
46-
expect(msg).toContain('Spec must have a Purpose section');
47-
expect(msg).toContain('Expected headers: "## Purpose" and "## Requirements"');
46+
expect(msg).toContain('規範必須包含目的區段');
47+
expect(msg).toContain('缺少必要區段');
4848
});
4949

5050
it('warns with scenario conversion template when missing scenarios', async () => {
@@ -65,9 +65,9 @@ Text of requirement
6565
const report = await validator.validateSpec(specPath);
6666
expect(report.valid).toBe(false);
6767
const warn = report.issues.find(i => i.path.includes('requirements[0].scenarios'));
68-
expect(warn?.message).toContain('Requirement must have at least one scenario');
69-
expect(warn?.message).toContain('Scenarios must use level-4 headers');
70-
expect(warn?.message).toContain('#### Scenario:');
68+
expect(warn?.message).toContain('需求必須至少有一個情境');
69+
expect(warn?.message).toContain('情境必須使用第四級標題');
70+
expect(warn?.message).toContain('#### 情境:');
7171
});
7272
});
7373

test/core/validation.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Validation Schemas', () => {
2929
const result = ScenarioSchema.safeParse(scenario);
3030
expect(result.success).toBe(false);
3131
if (!result.success) {
32-
expect(result.error.issues[0].message).toBe('Scenario text cannot be empty');
32+
expect(result.error.issues[0].message).toBe('情境文字不可為空');
3333
}
3434
});
3535
});
@@ -62,7 +62,7 @@ describe('Validation Schemas', () => {
6262
const result = RequirementSchema.safeParse(requirement);
6363
expect(result.success).toBe(false);
6464
if (!result.success) {
65-
expect(result.error.issues[0].message).toBe('Requirement must contain SHALL or MUST keyword');
65+
expect(result.error.issues[0].message).toBe('需求必須包含 SHALL MUST 關鍵字');
6666
}
6767
});
6868

@@ -75,7 +75,7 @@ describe('Validation Schemas', () => {
7575
const result = RequirementSchema.safeParse(requirement);
7676
expect(result.success).toBe(false);
7777
if (!result.success) {
78-
expect(result.error.issues[0].message).toBe('Requirement must have at least one scenario');
78+
expect(result.error.issues[0].message).toBe('需求必須至少有一個情境');
7979
}
8080
});
8181
});
@@ -111,7 +111,7 @@ describe('Validation Schemas', () => {
111111
const result = SpecSchema.safeParse(spec);
112112
expect(result.success).toBe(false);
113113
if (!result.success) {
114-
expect(result.error.issues[0].message).toBe('Spec must have at least one requirement');
114+
expect(result.error.issues[0].message).toBe('規範必須至少有一個需求');
115115
}
116116
});
117117
});
@@ -152,7 +152,7 @@ describe('Validation Schemas', () => {
152152
const result = ChangeSchema.safeParse(change);
153153
expect(result.success).toBe(false);
154154
if (!result.success) {
155-
expect(result.error.issues[0].message).toBe('Why section must be at least 50 characters');
155+
expect(result.error.issues[0].message).toBe('為什麼區段必須至少 50 個字元');
156156
}
157157
});
158158

@@ -173,7 +173,7 @@ describe('Validation Schemas', () => {
173173
const result = ChangeSchema.safeParse(change);
174174
expect(result.success).toBe(false);
175175
if (!result.success) {
176-
expect(result.error.issues[0].message).toBe('Consider splitting changes with more than 10 deltas');
176+
expect(result.error.issues[0].message).toBe('考慮拆分超過 10 個差異的變更');
177177
}
178178
});
179179
});
@@ -245,7 +245,7 @@ Then authenticated`;
245245

246246
expect(report.valid).toBe(false);
247247
expect(report.summary.errors).toBeGreaterThan(0);
248-
expect(report.issues.some(i => i.message.includes('Purpose'))).toBe(true);
248+
expect(report.issues.some(i => i.message.includes('目的'))).toBe(true);
249249
});
250250
});
251251

@@ -284,7 +284,7 @@ We need to implement user authentication to secure the application and protect u
284284

285285
expect(report.valid).toBe(false);
286286
expect(report.summary.errors).toBeGreaterThan(0);
287-
expect(report.issues.some(i => i.message.includes('Why'))).toBe(true);
287+
expect(report.issues.some(i => i.message.includes('為什麼'))).toBe(true);
288288
});
289289
});
290290

@@ -427,7 +427,7 @@ The system will log all events.
427427

428428
expect(report.valid).toBe(false);
429429
expect(report.summary.errors).toBeGreaterThan(0);
430-
expect(report.issues.some(i => i.message.includes('must contain SHALL or MUST'))).toBe(true);
430+
expect(report.issues.some(i => i.message.includes('必須包含 SHALL MUST'))).toBe(true);
431431
});
432432

433433
it('should handle requirements without metadata fields', async () => {

0 commit comments

Comments
 (0)