Skip to content

Commit

Permalink
feat(instance): add isSetup getter
Browse files Browse the repository at this point in the history
- uses System.hasInstance to determine if instance has been setup
  • Loading branch information
acburdine committed Oct 11, 2018
1 parent 65bc340 commit c81070c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ class Instance {
return true;
}

/**
* Returns whether or not the instance has been setup
*
* @property isSetup
* @type boolean
* @public
*/
get isSetup() {
return this.system.hasInstance(this);
}

/**
* Constructs the instance
*
Expand Down
15 changes: 15 additions & 0 deletions test/unit/instance-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ describe('Unit: Instance', function () {
it('cliVersion getter/setter works', testConfigAccessors('cliVersion', 'cli-version'));
it('previousVersion getter/setter works', testConfigAccessors('previousVersion', 'previous-version'));

it('isSetup accessor works', function () {
const hasInstance = sinon.stub();
hasInstance.onFirstCall().returns(true);
hasInstance.onSecondCall().returns(false);

const instance = new Instance({}, {hasInstance}, '/dir/a');

expect(instance.isSetup).to.be.true;
expect(hasInstance.calledOnce).to.be.true;
expect(hasInstance.calledWithExactly(instance)).to.be.true;

expect(instance.isSetup).to.be.false;
expect(hasInstance.calledTwice).to.be.true;
});

it('sets up instance vars in constructor', function () {
const testInstance = new Instance({ui: true}, {system: true}, 'some_test_dir');
expect(testInstance.ui).to.deep.equal({ui: true});
Expand Down

0 comments on commit c81070c

Please sign in to comment.