@@ -224,6 +224,62 @@ describe("Vim Command Integration Tests", () => {
224224 expect ( state . text ) . toBe ( "heXXllo" ) ;
225225 expect ( state . cursor ) . toBe ( 2 ) ;
226226 } ) ;
227+
228+ test ( "s substitutes character under cursor" , ( ) => {
229+ const state = executeVimCommands (
230+ { ...initialState , text : "hello" , cursor : 1 , mode : "normal" } ,
231+ [ "s" ]
232+ ) ;
233+ expect ( state . text ) . toBe ( "hllo" ) ;
234+ expect ( state . cursor ) . toBe ( 1 ) ;
235+ expect ( state . mode ) . toBe ( "insert" ) ;
236+ expect ( state . yankBuffer ) . toBe ( "e" ) ;
237+ } ) ;
238+
239+ test ( "s at end of text does nothing" , ( ) => {
240+ const state = executeVimCommands (
241+ { ...initialState , text : "hello" , cursor : 5 , mode : "normal" } ,
242+ [ "s" ]
243+ ) ;
244+ expect ( state . text ) . toBe ( "hello" ) ;
245+ expect ( state . mode ) . toBe ( "normal" ) ;
246+ } ) ;
247+
248+ test ( "~ toggles case of character under cursor" , ( ) => {
249+ const state = executeVimCommands (
250+ { ...initialState , text : "HeLLo" , cursor : 0 , mode : "normal" } ,
251+ [ "~" ]
252+ ) ;
253+ expect ( state . text ) . toBe ( "heLLo" ) ;
254+ expect ( state . cursor ) . toBe ( 1 ) ;
255+ } ) ;
256+
257+ test ( "~ toggles case and moves through word" , ( ) => {
258+ const state = executeVimCommands (
259+ { ...initialState , text : "HeLLo" , cursor : 0 , mode : "normal" } ,
260+ [ "~" , "~" , "~" ]
261+ ) ;
262+ expect ( state . text ) . toBe ( "hElLo" ) ;
263+ expect ( state . cursor ) . toBe ( 3 ) ;
264+ } ) ;
265+
266+ test ( "~ on non-letter does nothing but advances cursor" , ( ) => {
267+ const state = executeVimCommands (
268+ { ...initialState , text : "a 1 b" , cursor : 1 , mode : "normal" } ,
269+ [ "~" ]
270+ ) ;
271+ expect ( state . text ) . toBe ( "a 1 b" ) ;
272+ expect ( state . cursor ) . toBe ( 2 ) ;
273+ } ) ;
274+
275+ test ( "~ at end of text does not advance cursor" , ( ) => {
276+ const state = executeVimCommands (
277+ { ...initialState , text : "hello" , cursor : 4 , mode : "normal" } ,
278+ [ "~" ]
279+ ) ;
280+ expect ( state . text ) . toBe ( "hellO" ) ;
281+ expect ( state . cursor ) . toBe ( 4 ) ;
282+ } ) ;
227283 } ) ;
228284
229285 describe ( "Line Operations" , ( ) => {
0 commit comments