Skip to content

Commit

Permalink
Merge pull request #391 from babel/default-config
Browse files Browse the repository at this point in the history
Ensure `getSupportedExtensions` works when no config is provided.
  • Loading branch information
rwjblue authored Mar 18, 2021
2 parents 62f276a + 3a71f2f commit be2a598
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
return this._cachedDebugTree.apply(null, arguments);
},

getSupportedExtensions(config) {
getSupportedExtensions(config = {}) {
return _getExtensions(config, this.parent);
},

Expand Down
20 changes: 20 additions & 0 deletions node-tests/addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,26 @@ describe('ember-cli-babel', function() {
});
});

describe('getSupportedExtensions', function() {
it('defaults to js only', function() {
expect(this.addon.getSupportedExtensions()).to.have.members(['js']);
});

it('adds ts automatically', function() {
this.addon._shouldHandleTypeScript = function() { return true; }

expect(this.addon.getSupportedExtensions({ 'ember-cli-babel': { enableTypeScriptTransform: true }})).to.have.members(['js', 'ts']);
});

it('respects user-configured extensions', function() {
expect(this.addon.getSupportedExtensions({ 'ember-cli-babel': { extensions: ['coffee'] } })).to.have.members(['coffee']);
});

it('respects user-configured extensions even when adding TS plugin', function() {
expect(this.addon.getSupportedExtensions({ 'ember-cli-babel': { enableTypeScriptTransform: true, extensions: ['coffee'] } })).to.have.members(['coffee']);
});
});

describe('_getAddonOptions', function() {
it('uses parent options if present', function() {
let mockOptions = this.addon.parent.options = {};
Expand Down

0 comments on commit be2a598

Please sign in to comment.