@@ -728,15 +728,18 @@ def test_shell_plus(
728728 (['convert' , '.' ]),
729729 (['convert' , '.tmuxp.yaml' ]),
730730 (['convert' , '.tmuxp.yaml' , '-y' ]),
731+ (['convert' , '.tmuxp.yml' ]),
732+ (['convert' , '.tmuxp.yml' , '-y' ]),
731733 ],
732734)
733735def test_convert (cli_args , tmpdir , monkeypatch ):
734736 # create dummy tmuxp yaml so we don't get yelled at
735- tmpdir .join ('.tmuxp.yaml' ).write (
736- """
737- session_name: hello
738- """
739- )
737+ filename = cli_args [1 ]
738+ if filename == '.' :
739+ filename = '.tmuxp.yaml'
740+ file_ext = filename .rsplit ('.' , 1 )[- 1 ]
741+ assert file_ext in ['yaml' , 'yml' ], file_ext
742+ tmpdir .join (filename ).write ('\n session_name: hello\n ' )
740743 tmpdir .join ('.oh-my-zsh' ).ensure (dir = True )
741744 monkeypatch .setenv ('HOME' , str (tmpdir ))
742745
@@ -753,6 +756,31 @@ def test_convert(cli_args, tmpdir, monkeypatch):
753756 )
754757
755758
759+ @pytest .mark .parametrize (
760+ "cli_args" ,
761+ [
762+ (['convert' , '.' ]),
763+ (['convert' , '.tmuxp.json' ]),
764+ (['convert' , '.tmuxp.json' , '-y' ]),
765+ ],
766+ )
767+ def test_convert_json (cli_args , tmpdir , monkeypatch ):
768+ # create dummy tmuxp yaml so we don't get yelled at
769+ tmpdir .join ('.tmuxp.json' ).write ('{"session_name": "hello"}' )
770+ tmpdir .join ('.oh-my-zsh' ).ensure (dir = True )
771+ monkeypatch .setenv ('HOME' , str (tmpdir ))
772+
773+ with tmpdir .as_cwd ():
774+ runner = CliRunner ()
775+
776+ # If autoconfirm (-y) no need to prompt y
777+ input_args = 'y\n y\n ' if '-y' not in cli_args else ''
778+
779+ runner .invoke (cli .cli , cli_args , input = input_args )
780+ assert tmpdir .join ('.tmuxp.yaml' ).check ()
781+ assert tmpdir .join ('.tmuxp.yaml' ).open ().read () == 'session_name: hello\n '
782+
783+
756784@pytest .mark .parametrize ("cli_args" , [(['import' ])])
757785def test_import (cli_args , monkeypatch ):
758786 runner = CliRunner ()
0 commit comments