Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Commit d1f81d5

Browse files
committed
Make sure the directive prefix is tested
1 parent 4aeb5b9 commit d1f81d5

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

test/directive.spec.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ const make = function() {
2121
let checkForExamples;
2222
let construct;
2323
let creator;
24-
let dashToCap;
2524
let getTemplates;
26-
let filesSelectorPrefix;
2725
let inquire;
2826
let log;
2927
let logger;
3028
let parseOptions;
3129
let rooter;
32-
let testDashFormat;
3330

3431
tap.test('command: directive', (suite) => {
3532
suite.beforeEach((done) => {
@@ -38,7 +35,6 @@ tap.test('command: directive', (suite) => {
3835
checkForExamples = sandbox.stub(opts, 'checkIsForExamples');
3936
construct = sandbox.stub(erector, 'construct');
4037
creator = sandbox.stub(files.resolver, 'create');
41-
filesSelectorPrefix = sandbox.stub(files, 'selectorPrefix');
4238
getTemplates = sandbox.stub(files, 'getTemplates');
4339
inquire = sandbox.stub(erector, 'inquire');
4440
logger = sandbox.stub(logging, 'create');
@@ -125,6 +121,34 @@ tap.test('command: directive', (suite) => {
125121
});
126122
});
127123

124+
suite.test('should prefix the `selector` answer if one has been set', (test) => {
125+
const answers = [
126+
{ answer: 'bacon-blast', name: 'directiveName' },
127+
{ answer: 'PascalCaseDirective', name: 'className' },
128+
{ answer: 'myPascalSelector', name: 'selector' }
129+
];
130+
const checkDashFormat = sandbox.stub(caseConvert, 'checkIsDashFormat');
131+
const dashToCap = sandbox.stub(caseConvert, 'dashToCap');
132+
const dashToPascal = sandbox.stub(caseConvert, 'dashToPascal');
133+
134+
sandbox.stub(files, 'getSelectorPrefix').returns('my');
135+
136+
checkForExamples.returns(false);
137+
dashToCap.returns('PascalCase');
138+
dashToPascal.returns('PascalSelector');
139+
checkDashFormat.returns(true);
140+
141+
test.plan(2);
142+
make('bacon-blast').then(() => {
143+
test.notOk(inquire.called);
144+
test.ok(construct.calledWith(
145+
answers,
146+
'fake-templates'
147+
));
148+
test.end();
149+
});
150+
});
151+
128152
suite.test('should ask for a selector name in dash-case if NOT provided', (test) => {
129153
const dashToCap = sandbox.stub(caseConvert, 'dashToCap');
130154
test.plan(2);

0 commit comments

Comments
 (0)