@@ -10,8 +10,6 @@ describe('validate-config', function() {
10
10
} ) ;
11
11
12
12
beforeEach ( function ( ) {
13
- config = { } ;
14
-
15
13
mockUi = {
16
14
messages : [ ] ,
17
15
write : function ( ) { } ,
@@ -21,30 +19,70 @@ describe('validate-config', function() {
21
19
} ;
22
20
} ) ;
23
21
24
- it ( 'warns about missing optional config' , function ( ) {
25
- return assert . isFulfilled ( subject ( mockUi , config ) )
26
- . then ( function ( ) {
27
- var messages = mockUi . messages . reduce ( function ( previous , current ) {
28
- if ( / - M i s s i n g c o n f i g : \s .* , u s i n g d e f a u l t : \s / . test ( current ) ) {
29
- previous . push ( current ) ;
30
- }
22
+ describe ( 'without providing config' , function ( ) {
23
+ beforeEach ( function ( ) {
24
+ config = { } ;
25
+ } ) ;
26
+ it ( 'warns about missing optional config' , function ( ) {
27
+ return assert . isFulfilled ( subject ( mockUi , config ) )
28
+ . then ( function ( ) {
29
+ var messages = mockUi . messages . reduce ( function ( previous , current ) {
30
+ if ( / - M i s s i n g c o n f i g : \s .* , u s i n g d e f a u l t : \s / . test ( current ) ) {
31
+ previous . push ( current ) ;
32
+ }
31
33
32
- return previous ;
33
- } , [ ] ) ;
34
+ return previous ;
35
+ } , [ ] ) ;
34
36
35
- assert . equal ( messages . length , 3 ) ;
36
- } ) ;
37
- } ) ;
37
+ assert . equal ( messages . length , 3 ) ;
38
+ } ) ;
39
+ } ) ;
38
40
39
- it ( 'adds default config to the config object' , function ( ) {
40
- return assert . isFulfilled ( subject ( mockUi , config ) )
41
- . then ( function ( ) {
42
- assert . isDefined ( config . host ) ;
43
- assert . isDefined ( config . port ) ;
44
- } ) ;
41
+ it ( 'adds default config to the config object' , function ( ) {
42
+ return assert . isFulfilled ( subject ( mockUi , config ) )
43
+ . then ( function ( ) {
44
+ assert . isDefined ( config . host ) ;
45
+ assert . isDefined ( config . port ) ;
46
+ } ) ;
47
+ } ) ;
48
+
49
+ it ( 'resolves' , function ( ) {
50
+ return assert . isFulfilled ( subject ( mockUi , config ) ) ;
51
+ } )
45
52
} ) ;
46
53
47
- it ( 'resolves if config is ok' , function ( ) {
48
- return assert . isFulfilled ( subject ( mockUi , config ) ) ;
49
- } )
54
+ describe ( 'with a url provided' , function ( ) {
55
+ beforeEach ( function ( ) {
56
+ config = {
57
+ url : 'redis://localhost:6379'
58
+ } ;
59
+ } ) ;
60
+ it ( 'only warns about missing optional filePattern' , function ( ) {
61
+ return assert . isFulfilled ( subject ( mockUi , config ) )
62
+ . then ( function ( ) {
63
+ var messages = mockUi . messages . reduce ( function ( previous , current ) {
64
+ if ( / - M i s s i n g c o n f i g : \s .* , u s i n g d e f a u l t : \s / . test ( current ) ) {
65
+ previous . push ( current ) ;
66
+ }
67
+
68
+ return previous ;
69
+ } , [ ] ) ;
70
+
71
+ assert . equal ( messages . length , 1 ) ;
72
+ } ) ;
73
+ } ) ;
74
+
75
+ it ( 'does not add default config to the config object' , function ( ) {
76
+ return assert . isFulfilled ( subject ( mockUi , config ) )
77
+ . then ( function ( ) {
78
+ assert . isUndefined ( config . host ) ;
79
+ assert . isUndefined ( config . port ) ;
80
+ assert . isDefined ( config . filePattern ) ;
81
+ } ) ;
82
+ } ) ;
83
+
84
+ it ( 'resolves' , function ( ) {
85
+ return assert . isFulfilled ( subject ( mockUi , config ) ) ;
86
+ } )
87
+ } ) ;
50
88
} ) ;
0 commit comments