Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Commit c077d88

Browse files
committed
Fake prompt
`.template-lintrc` already exists when running this package blueprints. This is why the shell asks for confirmation. This is a work-around inspired by https://github.com/ember-cli/ember-cli-eslint/blob/v5.1.0/node-tests/blueprints/ember-cli-eslint-test.js
1 parent 1ace94f commit c077d88

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

node-tests/blueprints/ember-cli-template-lint-test.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const chai = require('ember-cli-blueprint-test-helpers/chai');
1010
const expect = chai.expect;
1111
const file = chai.file;
1212

13+
const td = require('testdouble');
14+
const MockUI = require('console-ui/mock');
15+
1316
describe('Acceptance: ember generate and destroy ember-cli-template-lint', function() {
1417
setupTestHooks(this);
1518

@@ -22,21 +25,32 @@ describe('Acceptance: ember generate and destroy ember-cli-template-lint', funct
2225
delete process.env.FORCE_LOCALIZED_FOR_TESTING;
2326
});
2427

28+
let prompt;
29+
beforeEach(function() {
30+
prompt = td.function();
31+
td.replace(MockUI.prototype, 'prompt', prompt);
32+
});
33+
34+
afterEach(function() {
35+
td.reset();
36+
});
37+
2538
it('ember-cli-template-lint without localization framework', co.wrap(function *() {
26-
let args = ['ember-cli-template-lint'];
39+
td.when(prompt(td.matchers.anything())).thenResolve({ answer: 'overwrite', deleteFiles: 'all' });
2740

2841
yield emberNew();
29-
yield emberGenerate(args);
42+
yield emberGenerate(['ember-cli-template-lint']);
3043

3144
expect(file('.template-lintrc.js')).to.contain('extends: \'octane\'');
3245
}));
3346

3447
it('ember-cli-template-lint with localization framework', co.wrap(function *() {
3548
process.env.FORCE_LOCALIZED_FOR_TESTING = true;
36-
let args = ['ember-cli-template-lint'];
49+
50+
td.when(prompt(td.matchers.anything())).thenResolve({ answer: 'overwrite', deleteFiles: 'all' });
3751

3852
yield emberNew();
39-
yield emberGenerate(args);
53+
yield emberGenerate(['ember-cli-template-lint']);
4054

4155
expect(file('.template-lintrc.js')).to.contain('extends: \'octane\'');
4256
expect(file('.template-lintrc.js')).to.contain('\'no-bare-strings\': true');

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"broccoli-test-helper": "^2.0.0",
4747
"chai": "^4.1.2",
4848
"co": "^4.6.0",
49+
"console-ui": "^3.1.1",
4950
"ember-cli": "~3.15.1",
5051
"ember-cli-babel": "^7.1.0",
5152
"ember-cli-blueprint-test-helpers": "^0.19.1",
@@ -67,7 +68,8 @@
6768
"mocha": "^7.0.0",
6869
"mocha-eslint": "^5.0.0",
6970
"mocha-only-detector": "^1.0.0",
70-
"qunit-dom": "^0.9.2"
71+
"qunit-dom": "^0.9.2",
72+
"testdouble": "^3.12.5"
7173
},
7274
"engines": {
7375
"node": "10.* || >=12.*"

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7130,6 +7130,14 @@ quibble@^0.5.5:
71307130
lodash "^4.17.2"
71317131
resolve "^1.7.1"
71327132

7133+
quibble@^0.5.6:
7134+
version "0.5.7"
7135+
resolved "https://registry.yarnpkg.com/quibble/-/quibble-0.5.7.tgz#34ea5467eee32dfa37968742a5af21b02cd6ebe0"
7136+
integrity sha512-QnHxlD12qhGGjvoEW4PIp8tA80tKjh5CxTg5wLTPp/aqvHElBA+Ag3JN0dWlHY96CUaJqSGmLxTLi+7wbysyZw==
7137+
dependencies:
7138+
lodash "^4.17.14"
7139+
resolve "^1.11.1"
7140+
71337141
quick-temp@^0.1.2, quick-temp@^0.1.3, quick-temp@^0.1.5, quick-temp@^0.1.8:
71347142
version "0.1.8"
71357143
resolved "https://registry.yarnpkg.com/quick-temp/-/quick-temp-0.1.8.tgz#bab02a242ab8fb0dd758a3c9776b32f9a5d94408"
@@ -8151,6 +8159,16 @@ [email protected]:
81518159
dependencies:
81528160
rimraf "~2.6.2"
81538161

8162+
testdouble@^3.12.5:
8163+
version "3.12.5"
8164+
resolved "https://registry.yarnpkg.com/testdouble/-/testdouble-3.12.5.tgz#fbc3a1a178a8251621e77dfa9f64a8e194b0175a"
8165+
integrity sha512-HxATrZ9Olip3bl/oW56uINeMAGDKjy2Q5CdoaCVTxcixN+BIOuPbiLDZ3OaE3d8vKsb4IZZr5Km5fTLZ5ha26g==
8166+
dependencies:
8167+
lodash "^4.17.15"
8168+
quibble "^0.5.6"
8169+
stringify-object-es5 "^2.5.0"
8170+
theredoc "^1.0.0"
8171+
81548172
testdouble@^3.2.6:
81558173
version "3.8.1"
81568174
resolved "https://registry.yarnpkg.com/testdouble/-/testdouble-3.8.1.tgz#8c74b6807f82fb07c2387a0640b4ae594b09b964"

0 commit comments

Comments
 (0)