diff --git a/index.js b/index.js index 992d341d..3f2402d0 100644 --- a/index.js +++ b/index.js @@ -83,7 +83,7 @@ module.exports = { return this._cachedDebugTree.apply(null, arguments); }, - getSupportedExtensions(config) { + getSupportedExtensions(config = {}) { return _getExtensions(config, this.parent); }, diff --git a/node-tests/addon-test.js b/node-tests/addon-test.js index d3d203be..b2900a7d 100644 --- a/node-tests/addon-test.js +++ b/node-tests/addon-test.js @@ -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 = {};