@@ -6,21 +6,21 @@ let fs = require('fs');
66let test = require ( 'tape' ) ;
77let writejson = require ( '..' ) ;
88
9- let tmp = os . tmpdir ( ) ;
10- let name = path . join ( tmp , String ( Math . random ( ) ) ) ;
11- let json = {
9+ const tmp = os . tmpdir ( ) ;
10+ const NAME = path . join ( tmp , String ( Math . random ( ) ) ) ;
11+ const json = {
1212 hello : 'world'
1313} ;
1414
1515test ( 'writejson: should write json data to file' , t => {
16- writejson ( name , json , error => {
16+ writejson ( NAME , json , error => {
1717 t . notOk ( error , 'no write error' ) ;
1818
19- fs . readFile ( name , 'utf8' , ( error , data ) => {
19+ fs . readFile ( NAME , 'utf8' , ( error , data ) => {
2020 t . notOk ( error , 'no read error' ) ;
2121 t . deepEqual ( json , JSON . parse ( data ) , 'data should be equal' ) ;
2222
23- fs . unlink ( name , error => {
23+ fs . unlink ( NAME , error => {
2424 t . notOk ( error , 'no remove error' ) ;
2525 t . end ( ) ;
2626 } ) ;
@@ -29,7 +29,7 @@ test('writejson: should write json data to file', t => {
2929} ) ;
3030
3131test ( 'writejson: no args' , t => {
32- t . throws ( writejson , / n a m e s h o u l d b e s t r i n g ! / , 'name check' ) ;
32+ t . throws ( writejson , / n a m e s h o u l d b e s t r i n g ! / , 'NAME check' ) ;
3333 t . end ( ) ;
3434} ) ;
3535
@@ -48,16 +48,16 @@ test('writejson: no callback', t => {
4848} ) ;
4949
5050test ( 'writejson.sync: should write json data to file synchonously' , t => {
51- writejson . sync ( name , json ) ;
52- let data = fs . readFileSync ( name , 'utf8' ) ;
51+ writejson . sync ( NAME , json ) ;
52+ let data = fs . readFileSync ( NAME , 'utf8' ) ;
5353 t . ok ( data , 'data should be read' ) ;
5454 t . deepEqual ( json , JSON . parse ( data ) , 'data should be equal' ) ;
55- fs . unlinkSync ( name ) ;
55+ fs . unlinkSync ( NAME ) ;
5656 t . end ( ) ;
5757} ) ;
5858
5959test ( 'writejson.sync: no args' , t => {
60- t . throws ( writejson . sync , / n a m e s h o u l d b e s t r i n g ! / , 'name check' ) ;
60+ t . throws ( writejson . sync , / n a m e s h o u l d b e s t r i n g ! / , 'NAME check' ) ;
6161 t . end ( ) ;
6262} ) ;
6363
@@ -69,7 +69,7 @@ test('writejson.sync: no json', t => {
6969} ) ;
7070
7171test ( 'writejson.sync.try: no args' , t => {
72- t . throws ( writejson . sync . try , / n a m e s h o u l d b e s t r i n g ! / , 'name check' ) ;
72+ t . throws ( writejson . sync . try , / n a m e s h o u l d b e s t r i n g ! / , 'NAME check' ) ;
7373 t . end ( ) ;
7474} ) ;
7575
0 commit comments