33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { default as assert } from 'assert' ;
7- import * as vscode from 'vscode' ;
8- import { SinonSandbox , createSandbox , SinonStub } from 'sinon' ;
9- import { Status } from '../api/api1' ;
10- import { MockRepository } from './mocks/mockRepository' ;
11-
12- // Import the function under test - we need to export it from commands.ts for testing
13- // For now, we'll test the integration by checking the mock calls
14-
15- describe ( 'Commands' , function ( ) {
16- let sinon : SinonSandbox ;
17- let showInformationMessageStub : SinonStub ;
18-
19- beforeEach ( function ( ) {
20- sinon = createSandbox ( ) ;
21- showInformationMessageStub = sinon . stub ( vscode . window , 'showInformationMessage' ) ;
22- } ) ;
23-
24- afterEach ( function ( ) {
25- sinon . restore ( ) ;
26- } ) ;
27-
28- describe ( 'handleUncommittedChanges' , function ( ) {
29- it ( 'should return true when there are no uncommitted changes' , async function ( ) {
30- const repository = new MockRepository ( ) ;
31- // Default state has no changes
32-
33- // Since we can't directly test the function (it's not exported),
34- // we test the behavior by checking that showInformationMessage is not called
35- // This is a minimal test to verify the basic logic
36- const hasWorkingTreeChanges = repository . state . workingTreeChanges . length > 0 ;
37- const hasIndexChanges = repository . state . indexChanges . length > 0 ;
38-
39- assert . strictEqual ( hasWorkingTreeChanges , false ) ;
40- assert . strictEqual ( hasIndexChanges , false ) ;
41- } ) ;
42-
43- it ( 'should detect working tree changes' , function ( ) {
44- const repository = new MockRepository ( ) ;
45-
46- // Add a working tree change
47- repository . state . workingTreeChanges . push ( {
48- uri : vscode . Uri . file ( '/test/file.txt' ) ,
49- originalUri : vscode . Uri . file ( '/test/file.txt' ) ,
50- renameUri : undefined ,
51- status : Status . MODIFIED ,
52- } ) ;
53-
54- const hasWorkingTreeChanges = repository . state . workingTreeChanges . length > 0 ;
55- assert . strictEqual ( hasWorkingTreeChanges , true ) ;
56- } ) ;
57-
58- it ( 'should detect index changes' , function ( ) {
59- const repository = new MockRepository ( ) ;
60-
61- // Add an index change
62- repository . state . indexChanges . push ( {
63- uri : vscode . Uri . file ( '/test/file.txt' ) ,
64- originalUri : vscode . Uri . file ( '/test/file.txt' ) ,
65- renameUri : undefined ,
66- status : Status . MODIFIED ,
67- } ) ;
68-
69- const hasIndexChanges = repository . state . indexChanges . length > 0 ;
70- assert . strictEqual ( hasIndexChanges , true ) ;
71- } ) ;
72-
73- it ( 'should properly mock repository.add and repository.clean methods' , async function ( ) {
74- const repository = new MockRepository ( ) ;
75-
76- // Mock the add method to succeed
77- sinon . stub ( repository , 'add' ) . resolves ( ) ;
78-
79- // Mock the clean method to succeed
80- sinon . stub ( repository , 'clean' ) . resolves ( ) ;
81-
82- // Test that the mocked methods work
83- await repository . add ( [ '/test/file.txt' ] ) ;
84- await repository . clean ( [ '/test/file.txt' ] ) ;
85-
86- // Verify the methods were called
87- assert . ok ( ( repository . add as SinonStub ) . calledOnce ) ;
88- assert . ok ( ( repository . clean as SinonStub ) . calledOnce ) ;
89- } ) ;
90- } ) ;
91- } ) ;
6+ // This file was created to test the handleUncommittedChanges functionality,
7+ // but the tests were removed as they only tested mocking capabilities
8+ // rather than meaningful functionality.
9+ //
10+ // The handleUncommittedChanges function is tested through manual testing
11+ // as documented in TESTING.md, since it primarily involves user interactions
12+ // with modal dialogs and git operations that are better tested in integration.
0 commit comments