@@ -33,21 +33,54 @@ test('CLI Tests', async (t) => {
3333 assert . ok ( result . stdout . includes ( 'Usage:' ) ) ;
3434 } ) ;
3535
36- await t . test ( 'should display version when run with --version ' , async ( ) => {
37- const result = await runCLI ( [ '--version' ] ) ;
36+ await t . test ( 'should display help when run without arguments ' , async ( ) => {
37+ const result = await runCLI ( [ ] ) ;
3838 assert . strictEqual ( result . code , 0 ) ;
39- assert . ok ( result . stdout . includes ( '1.0.0' ) ) ;
39+ assert . ok ( result . stdout . includes ( 'gitok' ) ) ;
40+ assert . ok ( result . stdout . includes ( 'Usage:' ) ) ;
4041 } ) ;
4142
42- await t . test ( 'should show error for missing URL argument ' , async ( ) => {
43- const result = await runCLI ( [ ] ) ;
43+ await t . test ( 'should show error for invalid Git URL ' , async ( ) => {
44+ const result = await runCLI ( [ 'https://bitbucket.org/owner/repo' ] ) ;
4445 assert . notStrictEqual ( result . code , 0 ) ;
45- assert . ok ( result . stderr . includes ( 'error' ) || result . stdout . includes ( 'required ') ) ;
46+ assert . ok ( result . stderr . includes ( 'Invalid Git URL format ' ) ) ;
4647 } ) ;
4748
48- await t . test ( 'should show error for invalid Git URL ' , async ( ) => {
49- const result = await runCLI ( [ 'https://bitbucket.org /owner/repo' ] ) ;
49+ await t . test ( 'should show error for URL with query parameters ' , async ( ) => {
50+ const result = await runCLI ( [ 'https://github.com /owner/repo?tab=readme ' ] ) ;
5051 assert . notStrictEqual ( result . code , 0 ) ;
5152 assert . ok ( result . stderr . includes ( 'Invalid Git URL format' ) ) ;
5253 } ) ;
54+
55+ await t . test ( 'should show error for URL with fragments' , async ( ) => {
56+ const result = await runCLI ( [ 'https://github.com/owner/repo#readme' ] ) ;
57+ assert . notStrictEqual ( result . code , 0 ) ;
58+ assert . ok ( result . stderr . includes ( 'Invalid Git URL format' ) ) ;
59+ } ) ;
60+
61+ await t . test ( 'should show error for empty URL' , async ( ) => {
62+ const result = await runCLI ( [ '' ] ) ;
63+ assert . notStrictEqual ( result . code , 0 ) ;
64+ assert . ok ( result . stderr . includes ( 'Invalid Git URL format' ) ) ;
65+ } ) ;
66+
67+ await t . test ( 'should validate GitHub URL format' , async ( ) => {
68+ const result = await runCLI ( [ 'https://github.com/invalid-url-format' ] ) ;
69+ assert . notStrictEqual ( result . code , 0 ) ;
70+ assert . ok ( result . stderr . includes ( 'Invalid Git URL format' ) ) ;
71+ } ) ;
72+
73+ await t . test ( 'should validate GitLab URL format' , async ( ) => {
74+ const result = await runCLI ( [ 'https://gitlab.com/invalid-url-format' ] ) ;
75+ assert . notStrictEqual ( result . code , 0 ) ;
76+ assert . ok ( result . stderr . includes ( 'Invalid Git URL format' ) ) ;
77+ } ) ;
78+
79+ await t . test ( 'should show usage examples in help text' , async ( ) => {
80+ const result = await runCLI ( [ '--help' ] ) ;
81+ assert . strictEqual ( result . code , 0 ) ;
82+ assert . ok ( result . stdout . includes ( 'Examples:' ) ) ;
83+ assert . ok ( result . stdout . includes ( 'github.com' ) ) ;
84+ assert . ok ( result . stdout . includes ( 'gitlab.com' ) ) ;
85+ } ) ;
5386} ) ;
0 commit comments