Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create isEmptyObject helper #191

Closed
5 tasks
n8rzz opened this issue Jan 29, 2017 · 0 comments
Closed
5 tasks

Create isEmptyObject helper #191

n8rzz opened this issue Jan 29, 2017 · 0 comments
Assignees
Labels
refactor Code changes that neither fix a defect nor add functionality
Milestone

Comments

@n8rzz
Copy link
Member

n8rzz commented Jan 29, 2017

if (!_isObject() || _isEmpty()) { ... }

This is a very common pattern throughout the app.

  • investigate if this is an existing method within lodash

if not:

  • abstract to a helper function
  • add tests
  • update usages
  • update existing tests to test only A vs B logic branches for new function

the following tests should all pass:

ava('.isEmptyObject() returns false when passed a non-object', (t) => {
    t.false(isEmptyObject('threeve'));
    t.false(isEmptyObject(false));
    t.false(isEmptyObject(42));
});

ava('.isEmptyObject() returns false when passed an object with properties', (t) => {
    t.false(isEmptyObject({
        a: 'threeve',
        b: 42,
        c: false
    }));
});

ava('.isEmptyObject() returns true when passed an empty object', (t) => {
    t.true(isEmptyObject({}));
    t.true(isEmptyObject([]));
    t.true(isEmptyObject(null));
});
@n8rzz n8rzz added the refactor Code changes that neither fix a defect nor add functionality label Jan 29, 2017
@n8rzz n8rzz assigned Dabea and unassigned Dabea Mar 22, 2017
@n8rzz n8rzz added this to the v4.2.0 milestone Mar 22, 2017
@Dabea Dabea mentioned this issue Apr 3, 2017
@n8rzz n8rzz added has pull request Add this label when an issue has a PR which will resolve it WIP Add this label to work-in-progress PRs which are not yet ready for review labels Apr 3, 2017
@n8rzz n8rzz modified the milestones: v5.1.0, v5.0.0 Apr 13, 2017
@erikquinn erikquinn removed the WIP Add this label to work-in-progress PRs which are not yet ready for review label Apr 24, 2017
@erikquinn erikquinn modified the milestones: v5.2.0, v5.1.0 Apr 28, 2017
@n8rzz n8rzz removed the has pull request Add this label when an issue has a PR which will resolve it label May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code changes that neither fix a defect nor add functionality
Projects
None yet
Development

No branches or pull requests

3 participants