1
1
'use strict'
2
- var FIXTURES , JSON , fs , parseJson , path , should
3
2
4
- fs = require ( 'fs' )
3
+ var parseJson = require ( 'parse-json' )
4
+ var should = require ( 'should' )
5
+ var path = require ( 'path' )
6
+ var jsonFuture = require ( '..' )
7
+ var fs = require ( 'fs' )
5
8
6
- JSON = require ( '..' )
7
-
8
- should = require ( 'should' )
9
-
10
- parseJson = require ( 'parse-json' )
11
-
12
- path = require ( 'path' )
13
-
14
- FIXTURES = {
9
+ var FIXTURES = {
15
10
string : '{\n "foo": "bar"\n}\n' ,
16
11
object : {
17
12
foo : 'bar'
@@ -24,71 +19,70 @@ describe('JSON Future ::', function () {
24
19
after ( function ( done ) {
25
20
return fs . unlink ( FIXTURES . path2 , done )
26
21
} )
22
+
27
23
describe ( 'sync' , function ( ) {
28
24
it ( '.parse' , function ( ) {
29
- var json
30
- json = JSON . parse ( FIXTURES . string )
31
- return json . foo . should . be . equal ( FIXTURES . object . foo )
25
+ var json = jsonFuture . parse ( FIXTURES . string )
26
+ json . foo . should . be . equal ( FIXTURES . object . foo )
32
27
} )
28
+
33
29
it ( '.stringify' , function ( ) {
34
- var string
35
- string = JSON . stringify ( FIXTURES . object )
36
- return string . should . be . equal ( FIXTURES . string )
30
+ var string = jsonFuture . stringify ( FIXTURES . object )
31
+ string . should . be . equal ( FIXTURES . string )
37
32
} )
33
+
38
34
it ( '.load' , function ( ) {
39
- var json
40
- json = JSON . load ( FIXTURES . path )
41
- return json . foo . should . be . equal ( FIXTURES . object . foo )
35
+ var json = jsonFuture . load ( FIXTURES . path )
36
+ json . foo . should . be . equal ( FIXTURES . object . foo )
42
37
} )
43
- return it ( '.save' , function ( ) {
44
- var json
45
- JSON . save ( FIXTURES . path2 , {
46
- hello : 'world'
47
- } )
48
- json = JSON . load ( FIXTURES . path2 )
49
- return json . hello . should . be . equal ( 'world' )
38
+
39
+ it ( '.save' , function ( ) {
40
+ jsonFuture . save ( FIXTURES . path2 , { hello : 'world' } )
41
+ var json = jsonFuture . load ( FIXTURES . path2 )
42
+ json . hello . should . be . equal ( 'world' )
50
43
} )
51
44
} )
52
- return describe ( 'async' , function ( ) {
45
+
46
+ describe ( 'async' , function ( ) {
53
47
describe ( '.parseAsync' , function ( ) {
54
48
it ( 'String' , function ( done ) {
55
- return JSON . parseAsync ( FIXTURES . string , function ( err , data ) {
49
+ jsonFuture . parseAsync ( FIXTURES . string , function ( err , data ) {
56
50
data . foo . should . be . equal ( FIXTURES . object . foo )
57
- return done ( err )
51
+ done ( err )
58
52
} )
59
53
} )
60
- return it ( 'Buffer' , function ( done ) {
61
- var buff
62
- buff = new Buffer ( FIXTURES . string )
63
- return JSON . parseAsync ( buff , function ( err , data ) {
54
+
55
+ it ( 'Buffer' , function ( done ) {
56
+ var buff = new Buffer ( FIXTURES . string )
57
+ jsonFuture . parseAsync ( buff , function ( err , data ) {
64
58
data . foo . should . be . equal ( FIXTURES . object . foo )
65
- return done ( err )
59
+ done ( err )
66
60
} )
67
61
} )
68
62
} )
63
+
69
64
it ( '.stringifyAsync' , function ( done ) {
70
- return JSON . stringifyAsync ( FIXTURES . object , function ( err , string ) {
65
+ jsonFuture . stringifyAsync ( FIXTURES . object , function ( err , string ) {
71
66
string . should . be . equal ( FIXTURES . string )
72
- return done ( err )
67
+ done ( err )
73
68
} )
74
69
} )
70
+
75
71
it ( '.loadAsync' , function ( done ) {
76
- return JSON . loadAsync ( FIXTURES . path , function ( err , json ) {
72
+ jsonFuture . loadAsync ( FIXTURES . path , function ( err , json ) {
77
73
json . foo . should . be . equal ( FIXTURES . object . foo )
78
- return done ( err )
74
+ done ( err )
79
75
} )
80
76
} )
81
- return it ( 'saveAsync' , function ( done ) {
82
- return JSON . saveAsync ( FIXTURES . path2 , {
77
+
78
+ it ( 'saveAsync' , function ( done ) {
79
+ jsonFuture . saveAsync ( FIXTURES . path2 , {
83
80
hello : 'world2'
84
81
} , function ( err ) {
85
- var json
86
- if ( err ) {
87
- return done ( err )
88
- }
89
- return json = JSON . loadAsync ( FIXTURES . path2 , function ( err , json ) {
82
+ if ( err ) return done ( err )
83
+ jsonFuture . loadAsync ( FIXTURES . path2 , function ( err , json ) {
90
84
json . hello . should . be . equal ( 'world2' )
91
- return done ( err )
85
+ done ( err )
92
86
} )
93
87
} )
94
88
} )
0 commit comments