@@ -98,14 +98,29 @@ describe('+ readFileSync()', function () {
98
98
} )
99
99
100
100
describe ( '> when invalid JSON and throws set to true' , function ( ) {
101
- it ( 'should return null ' , function ( ) {
101
+ it ( 'should throw an exception ' , function ( ) {
102
102
var file = path . join ( TEST_DIR , 'somefile4-invalid.json' )
103
103
var data = '{not valid JSON'
104
104
fs . writeFileSync ( file , data )
105
105
106
106
assert . throws ( function ( ) {
107
- jf . readFileSync ( file )
107
+ jf . readFileSync ( file , { throws : true } )
108
108
} )
109
+ } )
110
+ } )
111
+
112
+ describe ( '> when json file is missing and throws set to false' , function ( ) {
113
+ it ( 'should return null' , function ( ) {
114
+ var file = path . join ( TEST_DIR , 'somefile4-invalid.json' )
115
+
116
+ var obj = jf . readFileSync ( file , { throws : false } )
117
+ assert . strictEqual ( obj , null )
118
+ } )
119
+ } )
120
+
121
+ describe ( '> when json file is missing and throws set to true' , function ( ) {
122
+ it ( 'should throw an exception' , function ( ) {
123
+ var file = path . join ( TEST_DIR , 'somefile4-invalid.json' )
109
124
110
125
assert . throws ( function ( ) {
111
126
jf . readFileSync ( file , { throws : true } )
0 commit comments