@@ -18,8 +18,10 @@ vi.mock("configstore", () => ({
1818vi . mock ( "@stackcode/i18n" , ( ) => ( {
1919 t : vi . fn ( ( key : string ) => {
2020 const translations : Record < string , string > = {
21- "educational.conventional_commits_explanation" : "Conventional commits follow a standard that enables automation" ,
22- "educational.gitignore_explanation" : "A .gitignore file is being created to prevent secrets" ,
21+ "educational.conventional_commits_explanation" :
22+ "Conventional commits follow a standard that enables automation" ,
23+ "educational.gitignore_explanation" :
24+ "A .gitignore file is being created to prevent secrets" ,
2325 } ;
2426 return translations [ key ] || key ;
2527 } ) ,
@@ -41,19 +43,17 @@ describe("Educational Mode", () => {
4143 it ( "should enable educational mode when flag is true" , ( ) => {
4244 // Act
4345 initEducationalMode ( true ) ;
44- // Assert
46+ // Assert
4547 showEducationalMessage ( "educational.gitignore_explanation" ) ;
46- expect ( consoleSpy ) . toHaveBeenCalledWith (
47- expect . stringContaining ( "💡" )
48- ) ;
48+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
4949 } ) ;
5050
5151 it ( "should enable educational mode when global config is true" , ( ) => {
5252 // Arrange
5353 mockGet . mockReturnValue ( true ) ;
5454 // Act
5555 initEducationalMode ( false ) ;
56- // Assert
56+ // Assert
5757 expect ( mockGet ) . toHaveBeenCalledWith ( "educate" ) ;
5858 } ) ;
5959 it ( "should disable educational mode when flag is false and config is false" , ( ) => {
@@ -62,46 +62,40 @@ describe("Educational Mode", () => {
6262 // Act
6363 initEducationalMode ( false ) ;
6464 consoleSpy . mockClear ( ) ;
65- // Act
65+ // Act
6666 showEducationalMessage ( "educational.gitignore_explanation" ) ;
67- // Assert
67+ // Assert
6868 expect ( consoleSpy ) . not . toHaveBeenCalled ( ) ;
6969 } ) ;
7070 it ( "should enable educational mode when flag is true even if config is false" , ( ) => {
7171 // Arrange
7272 mockGet . mockReturnValue ( false ) ;
7373 // Act
7474 initEducationalMode ( true ) ;
75- // Assert
75+ // Assert
7676 showEducationalMessage ( "educational.gitignore_explanation" ) ;
77- expect ( consoleSpy ) . toHaveBeenCalledWith (
78- expect . stringContaining ( "💡" )
79- ) ;
77+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
8078 } ) ;
8179 } ) ;
8280 describe ( "showEducationalMessage" , ( ) => {
8381 beforeEach ( ( ) => {
84- initEducationalMode ( true ) ;
82+ initEducationalMode ( true ) ;
8583 } ) ;
8684
8785 it ( "should display educational message with correct icon when enabled" , ( ) => {
8886 // Act
8987 showEducationalMessage ( "educational.gitignore_explanation" ) ;
9088 // Assert
89+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
9190 expect ( consoleSpy ) . toHaveBeenCalledWith (
92- expect . stringContaining ( "💡" )
93- ) ;
94- expect ( consoleSpy ) . toHaveBeenCalledWith (
95- expect . stringContaining ( "A .gitignore file is being created" )
91+ expect . stringContaining ( "A .gitignore file is being created" ) ,
9692 ) ;
9793 } ) ;
9894 it ( "should show fallback message when translation is not found" , ( ) => {
99- // Act
95+ // Act
10096 showEducationalMessage ( "educational.nonexistent_key" ) ;
101- // Assert
102- expect ( consoleSpy ) . toHaveBeenCalledWith (
103- expect . stringContaining ( "💡" )
104- ) ;
97+ // Assert
98+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
10599 } ) ;
106100 it ( "should not display message when educational mode is disabled" , ( ) => {
107101 // Arrange
@@ -115,27 +109,23 @@ describe("Educational Mode", () => {
115109 } ) ;
116110 describe ( "showBestPractice" , ( ) => {
117111 beforeEach ( ( ) => {
118- initEducationalMode ( true ) ;
112+ initEducationalMode ( true ) ;
119113 } ) ;
120114 it ( "should display best practice message with correct icon when enabled" , ( ) => {
121115 // Act
122116 showBestPractice ( "educational.conventional_commits_explanation" ) ;
123117 // Assert
118+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "📚" ) ) ;
124119 expect ( consoleSpy ) . toHaveBeenCalledWith (
125- expect . stringContaining ( "📚" )
126- ) ;
127- expect ( consoleSpy ) . toHaveBeenCalledWith (
128- expect . stringContaining ( "Conventional commits follow" )
120+ expect . stringContaining ( "Conventional commits follow" ) ,
129121 ) ;
130122 } ) ;
131123
132124 it ( "should show fallback message for best practices when translation not found" , ( ) => {
133125 // Act
134126 showBestPractice ( "educational.unknown_practice" ) ;
135127 // Assert
136- expect ( consoleSpy ) . toHaveBeenCalledWith (
137- expect . stringContaining ( "📚" )
138- ) ;
128+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "📚" ) ) ;
139129 } ) ;
140130 it ( "should not display best practice when educational mode is disabled" , ( ) => {
141131 // Arrange
@@ -151,42 +141,47 @@ describe("Educational Mode", () => {
151141 it ( "should work with optional parameters in messages" , ( ) => {
152142 // Arrange
153143 initEducationalMode ( true ) ;
154- // Act
144+ // Act
155145 showEducationalMessage ( "educational.scaffold_explanation" ) ;
156146 // Assert
157- expect ( consoleSpy ) . toHaveBeenCalledWith (
158- expect . stringContaining ( "💡" )
159- ) ;
147+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
160148 } ) ;
161149 } ) ;
162150 describe ( "Educational Mode State Management" , ( ) => {
163151 it ( "should maintain state across multiple calls" , ( ) => {
164152 // Arrange
165153 initEducationalMode ( true ) ;
166- // Act
154+ // Act
167155 showEducationalMessage ( "educational.gitignore_explanation" ) ;
168156 showBestPractice ( "educational.conventional_commits_explanation" ) ;
169157 showEducationalMessage ( "educational.readme_explanation" ) ;
170- // Assert
158+ // Assert
171159 expect ( consoleSpy ) . toHaveBeenCalledTimes ( 3 ) ;
172- expect ( consoleSpy ) . toHaveBeenNthCalledWith ( 1 , expect . stringContaining ( "💡" ) ) ;
173- expect ( consoleSpy ) . toHaveBeenNthCalledWith ( 2 , expect . stringContaining ( "📚" ) ) ;
174- expect ( consoleSpy ) . toHaveBeenNthCalledWith ( 3 , expect . stringContaining ( "💡" ) ) ;
160+ expect ( consoleSpy ) . toHaveBeenNthCalledWith (
161+ 1 ,
162+ expect . stringContaining ( "💡" ) ,
163+ ) ;
164+ expect ( consoleSpy ) . toHaveBeenNthCalledWith (
165+ 2 ,
166+ expect . stringContaining ( "📚" ) ,
167+ ) ;
168+ expect ( consoleSpy ) . toHaveBeenNthCalledWith (
169+ 3 ,
170+ expect . stringContaining ( "💡" ) ,
171+ ) ;
175172 } ) ;
176173 it ( "should update behavior when mode is changed" , ( ) => {
177- // Arrange
174+ // Arrange
178175 mockGet . mockReturnValue ( false ) ;
179176 initEducationalMode ( false ) ;
180- // Act & Assert
177+ // Act & Assert
181178 showEducationalMessage ( "educational.gitignore_explanation" ) ;
182179 expect ( consoleSpy ) . not . toHaveBeenCalled ( ) ;
183- // Arrange
180+ // Arrange
184181 initEducationalMode ( true ) ;
185- // Act & Assert
182+ // Act & Assert
186183 showEducationalMessage ( "educational.gitignore_explanation" ) ;
187- expect ( consoleSpy ) . toHaveBeenCalledWith (
188- expect . stringContaining ( "💡" )
189- ) ;
184+ expect ( consoleSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "💡" ) ) ;
190185 } ) ;
191186 } ) ;
192187} ) ;
0 commit comments