diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..c339b8d --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,32 @@ +import pytest +from click.testing import CliRunner +from src.cli import main + + +@pytest.fixture +def runner(): + return CliRunner() + + +def test_cli_help(runner): + result = runner.invoke(main, ['--help']) + assert result.exit_code == 0 + assert 'LocalAPI Docs' in result.output + + +def test_cli_serve(runner, tmp_path, sample_spec): + result = runner.invoke(main, ['serve', str(sample_spec)]) + assert result.exit_code == 0 + + +def test_cli_generate(runner, tmp_path, sample_spec): + output = tmp_path / "output.html" + result = runner.invoke(main, ['generate', str(sample_spec), '-o', str(output)]) + assert result.exit_code == 0 + assert output.exists() + + +def test_cli_validate(runner, sample_spec): + result = runner.invoke(main, ['validate', str(sample_spec)]) + assert result.exit_code == 0 + assert 'valid' in result.output.lower()