@@ -4,75 +4,93 @@ describe('hash', () => {
4
4
test
5
5
. stdout ( )
6
6
. command ( [ 'hash' , 'ashish' ] )
7
- . it ( "cdt hash 'ashish'" , ctx => {
7
+ . it ( "Check default type -> cdt hash 'ashish'" , ctx => {
8
8
expect ( ctx . stdout ) . to . contain ( '428b6da53085b8fd7b37e9fb259c0c609bd09984' )
9
9
} )
10
10
11
+ //invalid type
12
+ test
13
+ . stdout ( )
14
+ . command ( [ 'hash' , '-t' , 'invalid' , 'ashish' ] )
15
+ . exit ( 0 )
16
+ . it ( "Invalid type -> cdt hash -t invalid 'ashish'" , ctx => {
17
+ expect ( ctx . stdout ) . to . contain ( 'Invalid Or Unsupported hash type' )
18
+ } )
19
+
20
+ //empty string
21
+ test
22
+ . stdout ( )
23
+ . command ( [ 'hash' , '-t' , 'md5' ] )
24
+ . exit ( 0 )
25
+ . it ( "Empty Input String -> cdt hash -t md5" , ctx => {
26
+ expect ( ctx . stdout ) . to . contain ( 'Input string is empty or undefined' )
27
+ } )
28
+
29
+
11
30
// passing sha1 as option
12
31
test
13
32
. stdout ( )
14
33
. command ( [ 'hash' , 'ashish' , '-t' , 'sha1' ] )
15
- . it ( "cdt hash 'ashish' -t 'sha1'" , ctx => {
34
+ . it ( "Passing Default type:sha -> cdt hash 'ashish' -t 'sha1'" , ctx => {
16
35
expect ( ctx . stdout ) . to . contain ( '428b6da53085b8fd7b37e9fb259c0c609bd09984' )
17
36
} )
18
37
19
38
//overriding string with option -s
20
39
test
21
40
. stdout ( )
22
41
. command ( [ 'hash' , '-s' , 'ashish' ] )
23
- . it ( "cdt hash -s 'ashish'" , ctx => {
42
+ . it ( "Passing string with -s flag -> cdt hash -s 'ashish'" , ctx => {
24
43
expect ( ctx . stdout ) . to . contain ( '428b6da53085b8fd7b37e9fb259c0c609bd09984' )
25
44
} )
26
45
27
46
// if both passed then need to take flag value of -s
28
47
test
29
48
. stdout ( )
30
49
. command ( [ 'hash' , 'patel' , '-s' , 'ashish' ] )
31
- . it ( "cdt hash 'patel' -s 'ashish'" , ctx => {
50
+ . it ( "Overriding argument string with -s flag -> cdt hash 'patel' -s 'ashish'" , ctx => {
32
51
expect ( ctx . stdout ) . to . contain ( '428b6da53085b8fd7b37e9fb259c0c609bd09984' )
33
52
} )
34
53
35
54
//sha256
36
55
test
37
56
. stdout ( )
38
57
. command ( [ 'hash' , '-t' , 'sha256' , 'ashish' ] )
39
- . it ( "cdt hash -t sha256 'ashish'" , ctx => {
58
+ . it ( "Hash Sha256 -> cdt hash -t sha256 'ashish'" , ctx => {
40
59
expect ( ctx . stdout ) . to . contain ( '05d08de271d2773a504b3a30f98df26cccda55689a8dc3514f55d3f247553d2b' )
41
60
} )
42
61
43
62
//md5
44
63
test
45
64
. stdout ( )
46
65
. command ( [ 'hash' , '--type' , 'md5' , 'ashish' ] )
47
- . it ( "cdt hash --type md5 'ashish'" , ctx => {
66
+ . it ( "Hash Md5 -> cdt hash --type md5 'ashish'" , ctx => {
48
67
expect ( ctx . stdout ) . to . contain ( '7b69ad8a8999d4ca7c42b8a729fb0ffd' )
49
68
} )
50
69
51
70
//sha512
52
71
test
53
72
. stdout ( )
54
73
. command ( [ 'hash' , '--type' , 'sha512' , 'ashish' ] )
55
- . it ( "cdt hash --type sha512 'ashish'" , ctx => {
74
+ . it ( "Hash Sha512 -> cdt hash --type sha512 'ashish'" , ctx => {
56
75
expect ( ctx . stdout ) . to . contain ( '2e076fcbd0e5dcb29d30da42a554de919864bbc29eaefe6d32c4f6bcb219d77ce5e48dada485dae92c918b10a03f42008c43ca721f06da6efa5fa9a223401907' )
57
76
} )
58
77
59
78
//rmd160
60
79
test
61
80
. stdout ( )
62
81
. command ( [ 'hash' , '--type' , 'rmd160' , 'ashish' ] )
63
- . it ( "cdt hash --type rmd160 'ashish'" , ctx => {
82
+ . it ( "Hash rmd160 -> cdt hash --type rmd160 'ashish'" , ctx => {
64
83
expect ( ctx . stdout ) . to . contain ( 'a85a72b0a240abecdf27f127aa75fd8663d6d5be' )
65
84
} )
66
85
67
86
//file input - file not found TODO: solve issue #4
68
- /*
69
87
test
70
- .stderr ()
88
+ . stdout ( )
71
89
. command ( [ 'hash' , '-f' , 'test/resources/filenotfound.txt' ] )
90
+ . exit ( 0 )
72
91
. it ( "cdt hash -f 'test/resources/filenotfound.txt'" , ctx => {
73
- expect(ctx.stderr ).to.contain('Error: reading File ')
92
+ expect ( ctx . stdout ) . to . contain ( 'Could not find file ' )
74
93
} )
75
- */
76
94
77
95
//file input
78
96
test
0 commit comments