@@ -24,9 +24,8 @@ function testAppender(label) {
24
24
test ( 'log4js configuration validation' , ( batch ) => {
25
25
batch . test ( 'should give error if config is just plain silly' , ( t ) => {
26
26
[ null , undefined , '' , ' ' , [ ] ] . forEach ( ( config ) => {
27
- const expectedError = new Error (
28
- `Problem with log4js configuration: (${ util . inspect ( config ) } ) - must be an object.`
29
- ) ;
27
+ const expectedError =
28
+ new Error ( `Problem with log4js configuration: (${ util . inspect ( config ) } ) - must be an object.` ) ;
30
29
t . throws (
31
30
( ) => new Configuration ( config ) ,
32
31
expectedError
@@ -37,34 +36,32 @@ test('log4js configuration validation', (batch) => {
37
36
} ) ;
38
37
39
38
batch . test ( 'should give error if config is an empty object' , ( t ) => {
40
- const expectedError = new Error (
41
- 'Problem with log4js configuration: ({}) - must have a property "appenders" of type object.'
42
- ) ;
39
+ const expectedError =
40
+ new Error ( 'Problem with log4js configuration: ({}) - must have a property "appenders" of type object.' ) ;
43
41
t . throws ( ( ) => new Configuration ( { } ) , expectedError ) ;
44
42
t . end ( ) ;
45
43
} ) ;
46
44
47
45
batch . test ( 'should give error if config has no appenders' , ( t ) => {
48
- const expectedError = new Error<
F438
/span>(
49
- 'Problem with log4js configuration: ({ categories: {} }) - must have a property "appenders" of type object.'
50
- ) ;
46
+ const expectedError =
47
+ new Error ( 'Problem with log4js configuration: ({ categories: {} }) ' +
48
+ '- must have a property "appenders" of type object.' ) ;
51
49
t . throws ( ( ) => new Configuration ( { categories : { } } ) , expectedError ) ;
52
50
t . end ( ) ;
53
51
} ) ;
54
52
55
53
batch . test ( 'should give error if config has no categories' , ( t ) => {
56
- const expectedError = new Error (
57
- 'Problem with log4js configuration: ({ appenders: {} }) - must have a property "categories" of type object.'
58
- ) ;
54
+ const expectedError =
55
+ new Error ( 'Problem with log4js configuration: ({ appenders: {} }) ' +
56
+ '- must have a property "categories" of type object.' ) ;
59
57
t . throws ( ( ) => new Configuration ( { appenders : { } } ) , expectedError ) ;
60
58
t . end ( ) ;
61
59
} ) ;
62
60
63
61
batch . test ( 'should give error if appenders is not an object' , ( t ) => {
64
- const error = new Error (
65
- 'Problem with log4js configuration: ({ appenders: [], categories: [] })' +
66
- ' - must have a property "appenders" of type object.'
67
- ) ;
62
+ const error =
63
+ new Error ( 'Problem with log4js configuration: ({ appenders: [], categories: [] })' +
64
+ ' - must have a property "appenders" of type object.' ) ;
68
65
t . throws (
69
66
( ) => new Configuration ( { appenders : [ ] , categories : [ ] } ) ,
70
67
error
@@ -73,10 +70,9 @@ test('log4js configuration validation', (batch) => {
73
70
} ) ;
74
71
75
72
batch . test ( 'should give error if appenders are not all valid' , ( t ) => {
76
- const error = new Error (
77
- 'Problem with log4js configuration: ({ appenders: { thing: \'cheese\' }, categories: {} })' +
78
- ' - appender "thing" is not valid (must be an object with property "type")'
79
- ) ;
73
+ const error =
74
+ new Error ( 'Problem with log4js configuration: ({ appenders: { thing: \'cheese\' }, categories: {} })' +
75
+ ' - appender "thing" is not valid (must be an object with property "type")' ) ;
80
76
t . throws (
81
77
( ) => new Configuration ( { appenders : { thing : 'cheese' } , categories : { } } ) ,
82
78
error
@@ -85,10 +81,8 @@ test('log4js configuration validation', (batch) => {
85
81
} ) ;
86
82
87
83
batch . test ( 'should require at least one appender' , ( t ) => {
88
- const error = new Error (
89
- 'Problem with log4js configuration: ({ appenders: {}, categories: {} })' +
90
- ' - must define at least one appender.'
91
- ) ;
84
+ const error = new Error ( 'Problem with log4js configuration: ({ appenders: {}, categories: {} })' +
85
+ ' - must define at least one appender.' ) ;
92
86
t . throws (
93
87
( ) => new Configuration ( { appenders : { } , categories : { } } ) ,
94
88
error
@@ -97,11 +91,9 @@ test('log4js configuration validation', (batch) => {
97
91
} ) ;
98
92
99
93
batch . test ( 'should give error if categories are not all valid' , ( t ) => {
100
- const error = new Error (
101
- 'Problem with log4js configuration: ' +
94
+ const error = new Error ( 'Problem with log4js configuration: ' +
102
95
'({ appenders: { stdout: { type: \'stdout\' } },\n categories: { thing: \'cheese\' } })' +
103
- ' - category "thing" is not valid (must be an object with properties "appenders" and "level")'
104
- ) ;
96
+ ' - category "thing" is not valid (must be an object with properties "appenders" and "level")' ) ;
105
97
t . throws (
106
98
( ) => new Configuration ( { appenders : { stdout : { type : 'stdout' } } , categories : { thing : 'cheese' } } ) ,
107
99
error
@@ -110,27 +102,24 @@ test('log4js configuration validation', (batch) => {
110
102
} ) ;
111
103
112
104
batch . test ( 'should give error if default category not defined' , ( t ) => {
113
- const error = new Error (
114
- 'Problem with log4js configuration: ' +
105
+ const error = new Error ( 'Problem with log4js configuration: ' +
115
106
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
116
107
' categories: { thing: { appenders: [ \'stdout\' ], level: \'ERROR\' } } })' +
117
- ' - must define a "default" category.'
118
- ) ;
108
+ ' - must define a "default" category.' ) ;
119
109
t . throws (
120
110
( ) => new Configuration ( {
121
111
appenders : { stdout : { type : 'stdout' } } ,
122
- categories : { thing : { appenders : [ 'stdout' ] , level : 'ERROR' } } }
123
- ) ,
112
+ categories : { thing : { appenders : [ 'stdout' ] , level : 'ERROR' } }
113
+ } ) ,
124
114
error
125
115
) ;
126
116
t . end ( ) ;
127
117
} ) ;
128
118
129
119
batch . test ( 'should require at least one category' , ( t ) => {
130
- const error = new Error (
131
- 'Problem with log4js configuration: ({ appenders: { stdout: { type: \'stdout\' } }, categories: {} })' +
132
- ' - must define at least one category.'
133
- ) ;
120
+ const error =
121
+ new Error ( 'Problem with log4js configuration: ({ appenders: { stdout: { type: \'stdout\' } }, categories: {} })' +
122
+ ' - must define at least one category.' ) ;
134
123
t . throws (
135
124
( ) => new Configuration ( { appenders : { stdout : { type : 'stdout' } } , categories : { } } ) ,
136
125
error
@@ -139,12 +128,10 @@ test('log4js configuration validation', (batch) => {
139
128
} ) ;
140
129
141
130
batch . test ( 'should give error if category.appenders is not an array' , ( t ) => {
142
- const error = new Error (
143
- 'Problem with log4js configuration: ' +
131
+ const error = new Error ( 'Problem with log4js configuration: ' +
144
132
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
145
133
' categories: { thing: { appenders: {}, level: \'ERROR\' } } })' +
146
- ' - category "thing" is not valid (appenders must be an array of appender names)'
147
- ) ;
134
+ ' - category "thing" is not valid (appenders must be an array of appender names)' ) ;
148
135
t . throws (
149
136
( ) => new Configuration ( {
150
137
appenders : { stdout : { type : 'stdout' } } ,
@@ -156,12 +143,10 @@ test('log4js configuration validation', (batch) => {
156
143
} ) ;
157
144
158
145
batch . test ( 'should give error if category.appenders is empty' , ( t ) => {
159
- const error = new Error (
160
- 'Problem with log4js configuration: ' +
146
+ const error = new Error ( 'Problem with log4js configuration: ' +
161
147
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
162
148
' categories: { thing: { appenders: [], level: \'ERROR\' } } })' +
163
- ' - category "thing" is not valid (appenders must contain at least one appender name)'
164
- ) ;
149
+ ' - category "thing" is not valid (appenders must contain at least one appender name)' ) ;
165
150
t . throws (
166
151
( ) => new Configuration ( {
167
152
appenders : { stdout : { type : 'stdout' } } ,
@@ -173,12 +158,10 @@ test('log4js configuration validation', (batch) => {
173
158
} ) ;
174
159
175
160
batch . test ( 'should give error if categories do not refer to valid appenders' , ( t ) => {
176
- const error = new Error (
177
- 'Problem with log4js configuration: ' +
161
+ const error = new Error ( 'Problem with log4js configuration: ' +
178
162
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
179
163
' categories: { thing: { appenders: [ \'cheese\' ], level: \'ERROR\' } } })' +
180
- ' - category "thing" is not valid (appender "cheese" is not defined)'
181
- ) ;
164
+ ' - category "thing" is not valid (appender "cheese" is not defined)' ) ;
182
165
t . throws (
183
166
( ) => new Configuration ( {
184
167
appenders : { stdout : { type : 'stdout' } } ,
@@ -190,13 +173,11 @@ test('log4js configuration validation', (batch) => {
190
173
} ) ;
191
174
192
175
batch . test ( 'should give error if category level is not valid' , ( t ) => {
193
- const error = new Error (
194
- 'Problem with log4js configuration: ' +
176
+ const error = new Error ( 'Problem with log4js configuration: ' +
195
177
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
196
178
' categories: { default: { appenders: [ \'stdout\' ], level: \'Biscuits\' } } })' +
197
179
' - category "default" is not valid (level "Biscuits" not recognised; ' +
198
- 'valid levels are ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, MARK, OFF)'
199
- ) ;
180
+ 'valid levels are ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, MARK, OFF)' ) ;
200
181
t . throws (
201
182
( ) => new Configuration ( {
202
183
appenders : { stdout : { type : 'stdout' } } ,
@@ -208,12 +189,10 @@ test('log4js configuration validation', (batch) => {
208
189
} ) ;
209
190
210
191
batch . test ( 'should give error if appender type cannot be found' , ( t ) => {
211
- const error = new Error (
212
57AE
code>
- 'Problem with log4js configuration: ' +
192
+ const error = new Error ( 'Problem with log4js configuration: ' +
213
193
'({ appenders: { thing: { type: \'cheese\' } },\n' +
214
194
' categories: { default: { appenders: [ \'thing\' ], level: \'ERROR\' } } })' +
215
- ' - appender "thing" is not valid (type "cheese" could not be found)'
216
- ) ;
195
+ ' - appender "thing" is not valid (type "cheese" could not be found)' ) ;
217
196
t . throws (
218
197
( ) => new Configuration ( {
219
198
appenders : { thing : { type : 'cheese' } } ,
@@ -278,9 +257,7 @@ test('log4js configuration validation', (batch) => {
278
257
sandboxConfig . requires [
279
258
`${ path . join ( mainPath , '../../node_modules/tap/node_modules/nyc/bin/cheese' ) } `
280
259
] = testAppender ( 'correct' ) ;
281
- const SandboxedConfiguration = sandbox . require (
282
- '../../lib/configuration' , sandboxConfig
283
- ) ;
260
+ const SandboxedConfiguration = sandbox . require ( '../../lib/configuration' , sandboxConfig ) ;
284
261
285
262
const config = new SandboxedConfiguration ( {
286
263
appenders : { thing : { type : 'cheese' } } ,
0 commit comments