Skip to content

Commit

Permalink
[FEATURE] Adds isFeatureExplicitlySet API
Browse files Browse the repository at this point in the history
This API lets us check if a feature is explicitly set (e.g. given a
value in the config)
  • Loading branch information
Chris Garrett committed Oct 23, 2019
1 parent 625aa48 commit b6de886
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ module.exports = {
return value !== undefined ? value : FEATURES[name].default;
},

isFeatureExplicitlySet(name) {
return this._features[name] !== undefined;
},

config() {
let EmberENV = {};
let features = this._features;
Expand Down
9 changes: 9 additions & 0 deletions tests/optional-features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ QUnit.module('@ember/optional-features', hooks => {
assert.strictEqual(addon.isFeatureEnabled('template-only-glimmer-components'), false, 'Expecting default value');
});

QUnit.test('it can query the features with `isFeatureExplicitlySet`', assert => {
let addon = buildAddon({
'application-template-wrapper': false
});

assert.strictEqual(addon.isFeatureExplicitlySet('application-template-wrapper'), true, 'Expecting value to exist');
assert.strictEqual(addon.isFeatureExplicitlySet('template-only-glimmer-components'), false, 'Expecting to not exist');
});

QUnit.test('it allows the config to be a overridden with an ENV variable', assert => {
process.env.EMBER_OPTIONAL_FEATURES = `{ "application-template-wrapper": false }`;

Expand Down

0 comments on commit b6de886

Please sign in to comment.