Skip to content

Commit 2b01f4e

Browse files
Scott TrinhScott Trinh
Scott Trinh
authored and
Scott Trinh
committed
fix: Use correct error handler parameter
Typo from renaming the error handler! Need more test coverage to catch little things like this...
1 parent 3640421 commit 2b01f4e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/angular-localForage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
deferred.resolve(localCopy);
140140
})
141141
.catch(function withError(error) {
142-
self.onError(data, args, self.setItem, deferred);
142+
self.onError(error, args, self.setItem, deferred);
143143
});
144144

145145
return deferred.promise;

tests/angular-localForage.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ describe('Module: LocalForageModule', function() {
202202
}, done);
203203
});
204204

205+
it('setItem error should reject promise', function(done) {
206+
var interval = triggerDigests();
207+
208+
spyOn($localForage._localforage, 'setItem').and.callFake(function() {
209+
return Promise.reject('Somebody set up us the bomb.')
210+
});
211+
212+
$localForage.setItem('myError', 'please work!').then(done).catch(function withError(error) {
213+
expect(error).toEqual('Somebody set up us the bomb.');
214+
done();
215+
});
216+
});
217+
205218
it('setItem and getItem should work with an array of keys', function(done) {
206219
var interval = triggerDigests(),
207220
values = ['Olivier Combe', 'AngularJs', 'Open Source'];

0 commit comments

Comments
 (0)