diff --git a/tests/test_cli.py b/tests/test_cli.py index 7219684c..16c9868f 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -139,3 +139,40 @@ class MyTests(unittest.TestCase): for test_dict, expected_json in zip(test_input, expected_output): self.assertEqual(jc.cli.json_out(test_dict), expected_json) + + def test_cli_json_out_monoc(self): + test_input = [ + None, + {}, + [], + '', + {"key1": "value1", "key2": 2, "key3": None, "key4": 3.14, "key5": True}, + ] + + expected_output = [ + 'null', + '{}', + '[]', + '""', + '{"key1": "value1", "key2": 2, "key3": null, "key4": 3.14, "key5": true}' + ] + + for test_dict, expected_json in zip(test_input, expected_output): + self.assertEqual(jc.cli.json_out(test_dict, mono=True), expected_json) + + def test_cli_json_out_pretty(self): + test_input = [ + {"key1": "value1", "key2": 2, "key3": None, "key4": 3.14, "key5": True}, + {"key1": [{"subkey1": "subvalue1"}, {"subkey2": [1, 2, 3]}], "key2": True} + ] + + expected_output = [ + '{\n \x1b[34;01m"key1"\x1b[39;00m: \x1b[32m"value1"\x1b[39m,\n \x1b[34;01m"key2"\x1b[39;00m: \x1b[35m2\x1b[39m,\n \x1b[34;01m"key3"\x1b[39;00m: \x1b[90mnull\x1b[39m,\n \x1b[34;01m"key4"\x1b[39;00m: \x1b[35m3.14\x1b[39m,\n \x1b[34;01m"key5"\x1b[39;00m: \x1b[90mtrue\x1b[39m\n}', + '{\n \x1b[34;01m"key1"\x1b[39;00m: [\n {\n \x1b[34;01m"subkey1"\x1b[39;00m: \x1b[32m"subvalue1"\x1b[39m\n },\n {\n \x1b[34;01m"subkey2"\x1b[39;00m: [\n \x1b[35m1\x1b[39m,\n \x1b[35m2\x1b[39m,\n \x1b[35m3\x1b[39m\n ]\n }\n ],\n \x1b[34;01m"key2"\x1b[39;00m: \x1b[90mtrue\x1b[39m\n}' + ] + + for test_dict, expected_json in zip(test_input, expected_output): + self.assertEqual(jc.cli.json_out(test_dict, pretty=True), expected_json) + + def test_cli_about_jc(self): + self.assertEqual(jc.cli.about_jc()['name'], 'jc')