Skip to content

Commit e08a53a

Browse files
committed
Update the method name.
1 parent c771baf commit e08a53a

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

src/js/ObjectValidator.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ class ObjectValidator {
1111
return ObjectValidator.isObj(obj) && obj !== null;
1212
}
1313

14-
static isEmpty(obj) {
15-
return !ObjectValidator.isValid(obj) || Object.keys(obj).length === 0;
16-
}
17-
18-
static isNotEmpty(obj) {
14+
static hasAnyProperty(obj) {
1915
return ObjectValidator.isValid(obj) && Object.keys(obj).length > 0;
2016
}
2117
}

test/ObjectValidator-spec.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,21 @@ describe('ObjectValidator', () => {
6868
});
6969
});
7070

71-
describe('#isEmpty', () => {
72-
it('should return true when given an empty obj', () => {
73-
expect(ObjectValidator.isEmpty(emptyObj)).to.be.true;
71+
describe('#hasAnyProperty', () => {
72+
it('should return true when given an obj which have some properties', () => {
73+
expect(ObjectValidator.hasAnyProperty(validObj)).to.be.true;
7474
});
7575

7676
it('should return true when given an undefined', () => {
77-
expect(ObjectValidator.isEmpty(undefined)).to.be.true;
77+
expect(ObjectValidator.hasAnyProperty(undefined)).to.be.false;
7878
});
7979

8080
it('should return true when given a null', () => {
81-
expect(ObjectValidator.isEmpty(null)).to.be.true;
82-
});
83-
84-
it('should return false when given an obj which have some properties', () => {
85-
expect(ObjectValidator.isEmpty(validObj)).to.be.false;
86-
});
87-
});
88-
89-
describe('#isNotEmpty', () => {
90-
it('should return true when given an obj which have some properties', () => {
91-
expect(ObjectValidator.isNotEmpty(validObj)).to.be.true;
81+
expect(ObjectValidator.hasAnyProperty(null)).to.be.false;
9282
});
9383

9484
it('should return false when given an empty obj', () => {
95-
expect(ObjectValidator.isNotEmpty(emptyObj)).to.be.false;
85+
expect(ObjectValidator.hasAnyProperty(emptyObj)).to.be.false;
9686
});
9787
});
9888
});

0 commit comments

Comments
 (0)