-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a better test for the
extraCliArgs
option
This uses testdouble.js to spy on the `ember` call that is done by `emberNew`.
- Loading branch information
Showing
2 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}); | ||
}); | ||
}); |