Skip to content

Commit

Permalink
fix: Use correct error handler parameter
Browse files Browse the repository at this point in the history
Typo from renaming the error handler! Need more test coverage to catch
little things like this...
  • Loading branch information
Scott Trinh authored and Scott Trinh committed Feb 22, 2017
1 parent 3640421 commit 2b01f4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/angular-localForage.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
deferred.resolve(localCopy);
})
.catch(function withError(error) {
self.onError(data, args, self.setItem, deferred);
self.onError(error, args, self.setItem, deferred);
});

return deferred.promise;
Expand Down
13 changes: 13 additions & 0 deletions tests/angular-localForage.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ describe('Module: LocalForageModule', function() {
}, done);
});

it('setItem error should reject promise', function(done) {
var interval = triggerDigests();

spyOn($localForage._localforage, 'setItem').and.callFake(function() {
return Promise.reject('Somebody set up us the bomb.')
});

$localForage.setItem('myError', 'please work!').then(done).catch(function withError(error) {
expect(error).toEqual('Somebody set up us the bomb.');
done();
});
});

it('setItem and getItem should work with an array of keys', function(done) {
var interval = triggerDigests(),
values = ['Olivier Combe', 'AngularJs', 'Open Source'];
Expand Down

0 comments on commit 2b01f4e

Please sign in to comment.