Align Bool isEmpty, true when false is wrapped (#1967)

This commit is contained in:
Jaco Greeff
2020-02-27 14:28:27 +01:00
committed by GitHub
parent 2823504156
commit 619ef6f8eb
3 changed files with 11 additions and 4 deletions
+8 -2
View File
@@ -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);
});
});
});
+2 -2
View File
@@ -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;
}
/**