You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test.js
+11-21Lines changed: 11 additions & 21 deletions
Original file line number
Original file line
Diff line number
Diff line change
@@ -208,7 +208,7 @@ module.exports = {
208
counter.should.equal(1);
208
counter.should.equal(1);
209
should.deepEqual(undefined,a.value);
209
should.deepEqual(undefined,a.value);
210
},
210
},
211
-
'should fall back last to the hook method as the error handler': function(){
211
+
'should fall back last to throwing the error': function(){
212
varA=function(){};
212
varA=function(){};
213
_.extend(A,hooks);
213
_.extend(A,hooks);
214
varcounter=0;
214
varcounter=0;
@@ -220,26 +220,16 @@ module.exports = {
220
next(newError());
220
next(newError());
221
});
221
});
222
vara=newA();
222
vara=newA();
223
-
a.save();
223
+
vardidCatch=false;
224
-
counter.should.equal(1);
224
+
try{
225
-
assert.equal(typeofa.value,'undefined');
225
+
a.save();
226
-
},
226
+
}catch(e){
227
-
'should have access to the object scope when falling back last to the hook method as the error handler': function(){
227
+
didCatch=true;
228
-
varA=function(){
228
+
e.should.be.an.instanceof(Error);
229
-
this.counter=0;
229
+
counter.should.equal(0);
230
-
};
230
+
assert.equal(typeofa.value,'undefined');
231
-
_.extend(A,hooks);
231
+
}
232
-
A.hook('save',function(err){
232
+
didCatch.should.be.true;
233
-
if(errinstanceofError)returnthis.counter++;
234
-
this.value=1;
235
-
});
236
-
A.pre('save',true,function(next,done){
237
-
next(newError());
238
-
});
239
-
vara=newA();
240
-
a.save();
241
-
a.counter.should.equal(1);
242
-
assert.equal(typeofa.value,'undefined');
243
},
233
},
244
"should proceed without mutating arguments if `next(null)` is called in a serial pre, and the last argument of the target method is a callback with node-like signature function (err, obj) {...} or function (err) {...}": function(){
234
"should proceed without mutating arguments if `next(null)` is called in a serial pre, and the last argument of the target method is a callback with node-like signature function (err, obj) {...} or function (err) {...}": function(){
0 commit comments