22
33var test = require ( 'tape' )
44var cept = require ( 'cept' )
5- var toJSON = require ( '.' )
5+ var toJson = require ( '.' )
66
7- test ( 'toJSON ' , function ( t ) {
8- t . equal ( typeof toJSON , 'function' , 'should be a `function`' )
7+ test ( 'toJson ' , function ( t ) {
8+ t . equal ( typeof toJson , 'function' , 'should be a `function`' )
99 t . end ( )
1010} )
1111
1212test ( 'Comments' , function ( t ) {
1313 t . deepEqual (
14- toJSON ( [ '% This is a completely commented line.' , 'unicorn' ] . join ( '\n' ) ) ,
14+ toJson ( [ '% This is a completely commented line.' , 'unicorn' ] . join ( '\n' ) ) ,
1515 [ 'unicorn' ] ,
1616 'should strip line comments'
1717 )
1818
1919 t . deepEqual (
20- toJSON ( 'unicorn % This is a partially commented line.' ) ,
20+ toJson ( 'unicorn % This is a partially commented line.' ) ,
2121 [ 'unicorn' ] ,
2222 'should strip partial line comments'
2323 )
2424
2525 t . deepEqual (
26- toJSON ( 'unicorn % This is a partially commented line.' , {
26+ toJson ( 'unicorn % This is a partially commented line.' , {
2727 comment : false
2828 } ) ,
2929 [ 'unicorn % This is a partially commented line.' ] ,
3030 'should honour `comment: false`'
3131 )
3232
3333 t . deepEqual (
34- toJSON ( [ '# This is a completely commented line.' , 'unicorn' ] . join ( '\n' ) , {
34+ toJson ( [ '# This is a completely commented line.' , 'unicorn' ] . join ( '\n' ) , {
3535 comment : '#'
3636 } ) ,
3737 [ 'unicorn' ] ,
3838 'should strip line comments based on a given token'
3939 )
4040
4141 t . deepEqual (
42- toJSON ( 'unicorn # This is a partially commented line.' , {
42+ toJson ( 'unicorn # This is a partially commented line.' , {
4343 comment : '#'
4444 } ) ,
4545 [ 'unicorn' ] ,
@@ -51,7 +51,7 @@ test('Comments', function(t) {
5151
5252test ( 'White space' , function ( t ) {
5353 t . deepEqual (
54- toJSON ( ' \tunicorn \t' ) ,
54+ toJson ( ' \tunicorn \t' ) ,
5555 [ 'unicorn' ] ,
5656 'should trim prefixed and suffixed white space'
5757 )
@@ -61,7 +61,7 @@ test('White space', function(t) {
6161
6262test ( 'Blank lines' , function ( t ) {
6363 t . deepEqual (
64- toJSON ( '\n \t \ndoge\n\nunicorn\r\n' ) ,
64+ toJson ( '\n \t \ndoge\n\nunicorn\r\n' ) ,
6565 [ 'doge' , 'unicorn' ] ,
6666 'should remove empty / blank lines'
6767 )
@@ -70,22 +70,22 @@ test('Blank lines', function(t) {
7070} )
7171
7272test ( 'EOF' , function ( t ) {
73- t . deepEqual ( toJSON ( 'unicorn' ) , [ 'unicorn' ] , 'No EOL' )
74- t . deepEqual ( toJSON ( 'unicorn\n' ) , [ 'unicorn' ] , 'LF' )
75- t . deepEqual ( toJSON ( 'unicorn\r\n' ) , [ 'unicorn' ] , 'CR+LF' )
73+ t . deepEqual ( toJson ( 'unicorn' ) , [ 'unicorn' ] , 'No EOL' )
74+ t . deepEqual ( toJson ( 'unicorn\n' ) , [ 'unicorn' ] , 'LF' )
75+ t . deepEqual ( toJson ( 'unicorn\r\n' ) , [ 'unicorn' ] , 'CR+LF' )
7676
7777 t . end ( )
7878} )
7979
8080test ( 'Property-value pairs' , function ( t ) {
8181 t . deepEqual (
82- toJSON ( 'unicorn: magic creature' ) ,
82+ toJson ( 'unicorn: magic creature' ) ,
8383 { unicorn : 'magic creature' } ,
8484 'should support pair delimiters'
8585 )
8686
8787 t . deepEqual (
88- toJSON (
88+ toJson (
8989 [
9090 'unicorn : magic creature' ,
9191 '\trainbow:double\t' ,
@@ -101,7 +101,7 @@ test('Property-value pairs', function(t) {
101101 )
102102
103103 t . deepEqual (
104- toJSON ( 'unicorn\tmagic creature' , { delimiter : '\t' } ) ,
104+ toJson ( 'unicorn\tmagic creature' , { delimiter : '\t' } ) ,
105105 { unicorn : 'magic creature' } ,
106106 'given delimiters'
107107 )
@@ -110,10 +110,10 @@ test('Property-value pairs', function(t) {
110110} )
111111
112112test ( 'Values' , function ( t ) {
113- t . deepEqual ( toJSON ( 'unicorn' ) , [ 'unicorn' ] , 'one value' )
113+ t . deepEqual ( toJson ( 'unicorn' ) , [ 'unicorn' ] , 'one value' )
114114
115115 t . deepEqual (
116- toJSON ( 'unicorn \n doge\n\trainbow' ) ,
116+ toJson ( 'unicorn \n doge\n\trainbow' ) ,
117117 [ 'doge' , 'rainbow' , 'unicorn' ] ,
118118 'multiple values'
119119 )
@@ -124,7 +124,7 @@ test('Values', function(t) {
124124test ( 'Mixed values' , function ( t ) {
125125 t . throws (
126126 function ( ) {
127- toJSON ( 'unicorn\nrainbow: double' )
127+ toJson ( 'unicorn\nrainbow: double' )
128128 } ,
129129 / ^ E r r o r : E r r o r a t ` r a i n b o w , d o u b l e ` / ,
130130 'should throw when both property-value pairs and values are provided'
@@ -136,14 +136,14 @@ test('Mixed values', function(t) {
136136test ( 'Invalid lists' , function ( t ) {
137137 t . throws (
138138 function ( ) {
139- toJSON ( 'unicorn\nrainbow\nunicorn' )
139+ toJson ( 'unicorn\nrainbow\nunicorn' )
140140 } ,
141141 / ^ E r r o r : E r r o r a t ` u n i c o r n ` : D u p l i c a t e d a t a f o u n d / ,
142142 'should throw when duplicate values exist'
143143 )
144144
145145 t . deepEqual (
146- toJSON ( 'unicorn\nrainbow\nunicorn' , { forgiving : true } ) ,
146+ toJson ( 'unicorn\nrainbow\nunicorn' , { forgiving : true } ) ,
147147 [ 'rainbow' , 'unicorn' , 'unicorn' ] ,
148148 'should honour forgiving'
149149 )
@@ -152,7 +152,7 @@ test('Invalid lists', function(t) {
152152 var stop = cept ( console , 'log' , hoist )
153153 var params
154154
155- toJSON ( 'unicorn\nrainbow\nunicorn' , { forgiving : true } )
155+ toJson ( 'unicorn\nrainbow\nunicorn' , { forgiving : true } )
156156
157157 stop ( )
158158
@@ -168,7 +168,7 @@ test('Invalid lists', function(t) {
168168 var stop = cept ( console , 'log' , hoist )
169169 var params
170170
171- toJSON ( 'unicorn\nrainbow\nunicorn' , { forgiving : true , log : false } )
171+ toJson ( 'unicorn\nrainbow\nunicorn' , { forgiving : true , log : false } )
172172
173173 stop ( )
174174
@@ -186,14 +186,14 @@ test('Invalid lists', function(t) {
186186test ( 'Invalid objects' , function ( t ) {
187187 t . throws (
188188 function ( ) {
189- toJSON ( 'doge: so scare\nunicorn: magic\ndoge: double' )
189+ toJson ( 'doge: so scare\nunicorn: magic\ndoge: double' )
190190 } ,
191191 / ^ E r r o r : E r r o r a t ` d o g e , d o u b l e ` : D u p l i c a t e d a t a f o u n d / ,
192192 'should throw when duplicate values exist'
193193 )
194194
195195 t . deepEqual (
196- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
196+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
197197 forgiving : true
198198 } ) ,
199199 { doge : 'so scare' , unicorn : 'magic creature' } ,
@@ -204,7 +204,7 @@ test('Invalid objects', function(t) {
204204 var stop = cept ( console , 'log' , hoist )
205205 var params
206206
207- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
207+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
208208 forgiving : true
209209 } )
210210
@@ -222,7 +222,7 @@ test('Invalid objects', function(t) {
222222 var stop = cept ( console , 'log' , hoist )
223223 var params
224224
225- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
225+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
226226 forgiving : true ,
227227 log : false
228228 } )
@@ -238,15 +238,15 @@ test('Invalid objects', function(t) {
238238 } )
239239
240240 t . deepEqual (
241- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
241+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
242242 forgiving : 'fix'
243243 } ) ,
244244 { doge : 'so scare' , unicorn : 'magic creature' } ,
245245 "should honour `forgiving: 'fix'`"
246246 )
247247
248248 t . deepEqual (
249- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: rainbows\n' , {
249+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: rainbows\n' , {
250250 forgiving : 'fix'
251251 } ) ,
252252 { doge : 'rainbows' , unicorn : 'magic creature' } ,
@@ -259,7 +259,7 @@ test('Invalid objects', function(t) {
259259 var stop = cept ( console , 'log' , hoist )
260260 var params
261261
262- toJSON ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
262+ toJson ( 'doge: so scare\nunicorn: magic creature\ndoge: so scare\n' , {
263263 forgiving : true
264264 } )
265265
0 commit comments