@@ -48,7 +48,7 @@ describe('.files (the MFS API part)', function () {
48
48
49
49
after ( ( done ) => fc . dismantle ( done ) )
50
50
51
- describe ( 'Callback API' , function ( ) {
51
+ describe . only ( 'Callback API' , function ( ) {
52
52
this . timeout ( 120 * 1000 )
53
53
54
54
it ( 'add file for testing' , ( done ) => {
@@ -106,13 +106,64 @@ describe('.files (the MFS API part)', function () {
106
106
} )
107
107
} )
108
108
109
- it ( 'files.add with progress options' , ( done ) => {
110
- let progress = 0
111
- ipfs . files . add ( testfile , { progress : ( p ) => { progress = p } } , ( err , res ) => {
109
+ it ( 'files.add file with progress option' , ( done ) => {
110
+ let progress
111
+ let progressCount = 0
112
+
113
+ const progressHandler = ( p ) => {
114
+ progressCount += 1
115
+ progress = p
116
+ }
117
+
118
+ ipfs . files . add ( testfile , { progress : progressHandler } , ( err , res ) => {
119
+ expect ( err ) . to . not . exist ( )
120
+
121
+ expect ( res ) . to . have . length ( 1 )
122
+ expect ( progress ) . to . be . equal ( 100 )
123
+ expect ( progressCount ) . to . be . greaterThan ( 0 )
124
+
125
+ done ( )
126
+ } )
127
+ } )
128
+
129
+ it ( 'files.add big file with progress option' , ( done ) => {
130
+ let progress
131
+ let progressCount = 0
132
+
133
+ const progressHandler = ( p ) => {
134
+ progressCount += 1
135
+ progress = p
136
+ }
137
+
138
+ // TODO: needs to be using a big file
139
+ ipfs . files . add ( testfile , { progress : progressHandler } , ( err , res ) => {
112
140
expect ( err ) . to . not . exist ( )
113
141
114
142
expect ( res ) . to . have . length ( 1 )
115
- expect ( progress ) . to . be . greaterThan ( 0 )
143
+ expect ( progress ) . to . be . equal ( 100 )
144
+ expect ( progressCount ) . to . be . greaterThan ( 0 )
145
+
146
+ done ( )
147
+ } )
148
+ } )
149
+
150
+ it ( 'files.add directory with progress option' , ( done ) => {
151
+ let progress
152
+ let progressCount = 0
153
+
154
+ const progressHandler = ( p ) => {
155
+ progressCount += 1
156
+ progress = p
157
+ }
158
+
159
+ // TODO: needs to be using a directory
160
+ ipfs . files . add ( testfile , { progress : progressHandler } , ( err , res ) => {
161
+ expect ( err ) . to . not . exist ( )
162
+
163
+ expect ( res ) . to . have . length ( 1 )
164
+ expect ( progress ) . to . be . equal ( 100 )
165
+ expect ( progressCount ) . to . be . greaterThan ( 0 )
166
+
116
167
done ( )
117
168
} )
118
169
} )
0 commit comments