diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9918a396..d72ac99b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Allow `BTreeMap` to be initialized with a `Record` object (in addition to `Map`) - Allow for `HashMap` definitions +- `Bool` will now correctly return `isEmpty` on false/default values - Refresh the `NetworkState` types as returned by the `rpc.system.networkState()` call to current - Expose `registry.createClass()`, to allow for creating type classes. If you are using `createClass` or `ClassOf` in your code, it is recommended to swap to this instance. diff --git a/packages/types/src/primitive/Bool.spec.ts b/packages/types/src/primitive/Bool.spec.ts index 8718c7329c..31e1615c3c 100644 --- a/packages/types/src/primitive/Bool.spec.ts +++ b/packages/types/src/primitive/Bool.spec.ts @@ -42,11 +42,11 @@ describe('Bool', (): void => { }); describe('utils', (): void => { - it('compares agains a boolean', (): void => { + it('compares against a boolean', (): void => { expect(new Bool(registry, true).eq(true)).toBe(true); }); - it('compares agains a Bool', (): void => { + it('compares against a Bool', (): void => { expect(new Bool(registry, false).eq(new Bool(registry, false))).toBe(true); }); @@ -57,5 +57,11 @@ describe('Bool', (): void => { it('has isFalse', (): void => { expect(new Bool(registry, true).isFalse).toBe(false); }); + + it('has sane isEmpty aligning with the rest', (): void => { + expect(new Bool(registry).isEmpty).toBe(true); + expect(new Bool(registry, false).isEmpty).toBe(true); + expect(new Bool(registry, true).isEmpty).toBe(false); + }); }); }); diff --git a/packages/types/src/primitive/Bool.ts b/packages/types/src/primitive/Bool.ts index 9f2976aac2..5d926329d5 100644 --- a/packages/types/src/primitive/Bool.ts +++ b/packages/types/src/primitive/Bool.ts @@ -50,10 +50,10 @@ export default class Bool extends Boolean implements Codec { } /** - * @description Checks if the value is an empty value (always false) + * @description Checks if the value is an empty value (true when it wraps false/default) */ public get isEmpty (): boolean { - return false; + return this.isFalse; } /**