@@ -21,12 +21,12 @@ vi.mock('openai', () => {
2121 }
2222} )
2323
24- // index.jsモジュール全体をモック
24+ // Mock the entire index.js module
2525vi . mock ( '../index.js' , ( ) => {
2626 return {
2727 getGitSummary : vi . fn ( ( options ) => {
2828 try {
29- // 実際のdiffコマンドを実行せず、ファイルの変更があるかチェック
29+ // Check if there are file changes without actually executing the diff command
3030 const gitStatus = require ( 'child_process' )
3131 . execSync ( 'git status --porcelain' )
3232 . toString ( )
@@ -35,8 +35,8 @@ vi.mock('../index.js', () => {
3535 throw new Error ( 'No changes to commit' )
3636 }
3737
38- // モックされたdiffの内容を返す
39- return `diff --git a/file1.js b/file1.js\nindex 123456..789012 100644\n--- a/file1.js\n+++ b/file1.js\n@@ -1,5 +1,8 @@\nfunction greet(name) {\n- return \`Hello, \${name}!\`;\n+ // 名前が空の場合のデフォルト値を追加 \n+ const userName = name || 'Guest';\n+ return \`Hello, \${userName}!\`;\n }`
38+ // Return mocked diff content
39+ return `diff --git a/file1.js b/file1.js\nindex 123456..789012 100644\n--- a/file1.js\n+++ b/file1.js\n@@ -1,5 +1,8 @@\nfunction greet(name) {\n- return \`Hello, \${name}!\`;\n+ // Add default value when name is empty \n+ const userName = name || 'Guest';\n+ return \`Hello, \${userName}!\`;\n }`
4040 } catch ( error ) {
4141 throw new Error ( 'Failed to get git summary' )
4242 }
@@ -45,40 +45,40 @@ vi.mock('../index.js', () => {
4545 return 'Mock commit message'
4646 } ) ,
4747 gitExtension : vi . fn ( ) ,
48- // その他必要な関数やオブジェクト
48+ // Other necessary functions or objects
4949 }
5050} )
5151
52- // fs モジュールをモック
52+ // Mock fs module
5353vi . mock ( 'fs' , async ( ) => {
5454 const actual = await vi . importActual ( 'fs' )
5555
5656 return {
5757 ...actual ,
5858 existsSync : vi . fn ( ( path ) => {
59- // 特定のパスのみモックレスポンスを返す
59+ // Return mock response only for specific paths
6060 if ( path . includes ( '.git-gpt-commit-config.json' ) ) {
6161 return true
6262 }
63- // それ以外は実際の実装を使用
63+ // Use actual implementation for others
6464 return actual . existsSync ( path )
6565 } ) ,
6666 readFileSync : vi . fn ( ( path , options ) => {
67- // コンフィグファイルの場合、モックデータを返す
67+ // Return mock data for config file
6868 if ( path . includes ( '.git-gpt-commit-config.json' ) ) {
6969 return JSON . stringify ( {
7070 model : 'gpt-4o' ,
7171 language : 'English' ,
7272 } )
7373 }
74- // それ以外は実際の実装を使用
74+ // Use actual implementation for others
7575 return actual . readFileSync ( path , options )
7676 } ) ,
7777 writeFileSync : vi . fn ( ) ,
7878 }
7979} )
8080
81- // commanderをモック
81+ // Mock commander
8282vi . mock ( 'commander' , ( ) => {
8383 const mockProgram = {
8484 command : vi . fn ( ) . mockReturnThis ( ) ,
@@ -95,32 +95,32 @@ vi.mock('commander', () => {
9595 }
9696} )
9797
98- // child_processをモック
98+ // Mock child_process
9999vi . mock ( 'child_process' , async ( ) => {
100100 const actual = await vi . importActual ( 'child_process' )
101101
102102 return {
103103 ...actual ,
104104 execSync : vi . fn ( ( command ) => {
105105 if ( typeof command === 'string' ) {
106- // git statusコマンドの場合は変更があるとみなす
106+ // Treat as having changes for git status commands
107107 if ( command . includes ( 'git status' ) ) {
108108 return Buffer . from ( 'M file1.js' )
109109 }
110110
111- // git commitコマンドの場合はモック応答
111+ // Mock response for git commit commands
112112 if ( command . includes ( 'git commit' ) ) {
113113 return Buffer . from ( 'Commit successful' )
114114 }
115115 }
116116
117- // その他のコマンドは実際に実行
117+ // Actually execute other commands
118118 return actual . execSync ( command )
119119 } ) ,
120120 exec : vi . fn ( ( command , callback ) => {
121121 if ( command . includes ( 'git diff' ) ) {
122122 const stdout =
123- "diff --git a/file1.js b/file1.js\nindex 123456..789012 100644\n--- a/file1.js\n+++ b/file1.js\n@@ -1,5 +1,8 @@\nfunction greet(name) {\n- return `Hello, ${name}!`;\n+ // 名前が空の場合のデフォルト値を追加 \n+ const userName = name || 'Guest';\n+ return `Hello, ${userName}!`;\n }"
123+ "diff --git a/file1.js b/file1.js\nindex 123456..789012 100644\n--- a/file1.js\n+++ b/file1.js\n@@ -1,5 +1,8 @@\nfunction greet(name) {\n- return \ `Hello, \ ${name}!\ `;\n+ // Add default value when name is empty \n+ const userName = name || 'Guest';\n+ return \ `Hello, \ ${userName}!\ `;\n }"
124124 callback ( null , { stdout } )
125125 } else {
126126 callback ( null , { stdout : '' } )
@@ -129,12 +129,12 @@ vi.mock('child_process', async () => {
129129 }
130130} )
131131
132- // promptsモジュールをモック
132+ // Mock prompts module
133133vi . mock ( 'prompts' , ( ) => ( {
134134 default : vi . fn ( ) . mockResolvedValue ( { value : true } ) ,
135135} ) )
136136
137- // process.exitをモック
137+ // Mock process.exit
138138vi . stubGlobal ( 'process' , {
139139 ...process ,
140140 exit : vi . fn ( ( code ) => {
0 commit comments