Skip to content
Permalink
Browse files

fix: default value logic in local storage service

  • Loading branch information
ike18t committed Feb 21, 2018
1 parent eddabe8 commit d965a74074717c667db4b12669a1d6367dd2539f
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/local-storage-flipper.service.spec.ts
  2. +2 −1 src/local-storage-flipper.service.ts
@@ -19,7 +19,7 @@ describe('LocalStorageFlipperService', () => {
});

it('returns false if the value is false in the persisted object and the initial value is false', () => {
expect(service.isEnabled('bar', false)).toBe(false);
expect(service.isEnabled('bar', true)).toBe(false);
});

it('returns true if the default value true and there is no key in storage', () => {
@@ -17,7 +17,8 @@ export class LocalStorageFlipperService implements FlipperService {
}

isEnabled(toggleName: string, defaultValue: boolean = false): boolean {
return this.toggles[toggleName] || defaultValue;
const toggleValue = this.toggles[toggleName];
return toggleValue === undefined ? defaultValue : toggleValue;
}

private toggle(toggleName: string, enable: boolean) {

0 comments on commit d965a74

Please sign in to comment.
You can’t perform that action at this time.