Align Bool isEmpty, true when false is wrapped (#1967)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
- Allow `BTreeMap` to be initialized with a `Record<string, any>` object (in addition to `Map`)
|
||||
- Allow for `HashMap<KeyType, ValueType>` 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(<typeName>)`, to allow for creating type classes. If you are using `createClass` or `ClassOf` in your code, it is recommended to swap to this instance.
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user