diff --git a/tests/acceptance/helpers-test.js b/tests/acceptance/helpers-test.js index d544fa5..6ac974a 100644 --- a/tests/acceptance/helpers-test.js +++ b/tests/acceptance/helpers-test.js @@ -33,14 +33,6 @@ describe('Acceptance: helpers', function () { expect(fs.existsSync(addonPath)).to.equal(true); }); }); - - it('emberNew - extraCliArgs', () => { - return emberNew({ extraCliArgs: ['--typescript', '--no-welcome']}) - .then(() => { - const appPath = path.resolve(process.cwd(), 'app'); - expect(fs.existsSync(appPath)).to.equal(true); - }); - }); }); describe('emberGenerateDestroy', () => { diff --git a/tests/unit/ember-new-test.js b/tests/unit/ember-new-test.js new file mode 100644 index 0000000..42aba2e --- /dev/null +++ b/tests/unit/ember-new-test.js @@ -0,0 +1,38 @@ +'use strict'; +const setupTestHooks = require('../../lib/helpers/setup'); + +const chai = require('../../chai'); +const expect = chai.expect; +const td = require('testdouble') + +let ember; + +describe('Unit: emberNew', function () { + setupTestHooks(this); + + afterEach(() => { + td.reset(); + ember = undefined; + }); + + it('emberNew - extraCliArgs', () => { + const originalEmber = require('../../lib/helpers/ember.js'); + ember = td.replace('../../lib/helpers/ember.js'); + + // "spy" on the original ember function. + // testdouble.js doesn't have built-in support for this because it considers it a bad practise: + // https://github.com/testdouble/testdouble.js/issues/512#issuecomment-1527511338 + td.when(ember(td.matchers.contains('--typescript', '--no-welcome'), td.matchers.anything())).thenDo((...args) => { + return originalEmber(...args); + }); + + // We require emberNew here so the testdouble dependency replacement works + const emberNew = require('../../lib/ember-new'); + + return emberNew({ extraCliArgs: ['--typescript', '--no-welcome'] }) + .then(() => { + // If we get here that means our testdouble matcher worked and things were called as expected. + expect(true).to.be.true; + }); + }); +});