Skip to content

Commit dd155b1

Browse files
broudeddiemonge
authored andcommitted
fix(test): add test for eventual appPath option
The tests are currently commented out until the actual functionality is implemented Closes yeoman#630
1 parent cf3b635 commit dd155b1

File tree

1 file changed

+210
-0
lines changed

1 file changed

+210
-0
lines changed

test/test-apppath.js

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
// /*global describe, before, it, beforeEach */
2+
// 'use strict';
3+
//
4+
// var fs = require('fs');
5+
// var assert = require('assert');
6+
// var path = require('path');
7+
// var util = require('util');
8+
// var generators = require('yeoman-generator');
9+
// var helpers = require('yeoman-generator').test;
10+
// var _ = require('underscore.string');
11+
//
12+
// describe('Angular generator appPath option', function () {
13+
// var angular;
14+
// var appPath = 'customAppPath';
15+
// var expected = [
16+
// appPath + '/.htaccess',
17+
// appPath + '/404.html',
18+
// appPath + '/favicon.ico',
19+
// appPath + '/robots.txt',
20+
// appPath + '/styles/main.scss',
21+
// appPath + '/views/main.html',
22+
// appPath + '/index.html',
23+
// '.bowerrc',
24+
// '.editorconfig',
25+
// '.gitignore',
26+
// '.jshintrc',
27+
// 'Gruntfile.js',
28+
// 'package.json',
29+
// 'bower.json'
30+
// ];
31+
// var mockPrompts = {
32+
// compass: true,
33+
// bootstrap: true,
34+
// compassBootstrap: true,
35+
// modules: []
36+
// };
37+
// var genOptions = {
38+
// 'app-path': appPath,
39+
// 'skip-install': true,
40+
// 'skip-welcome-message': true,
41+
// 'skip-message': true
42+
// };
43+
//
44+
// beforeEach(function (done) {
45+
// var deps = [
46+
// '../../app',
47+
// '../../common',
48+
// '../../controller',
49+
// '../../main', [
50+
// helpers.createDummyGenerator(),
51+
// 'karma:app'
52+
// ]
53+
// ];
54+
// helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
55+
// if (err) {
56+
// done(err);
57+
// }
58+
// angular = helpers.createGenerator('angular:app', deps, false, genOptions);
59+
// done();
60+
// });
61+
// });
62+
//
63+
// it('should generate dotfiles', function (done) {
64+
// helpers.mockPrompt(angular, mockPrompts);
65+
//
66+
// angular.run({}, function () {
67+
// helpers.assertFile(expected);
68+
// done();
69+
// });
70+
// });
71+
//
72+
// it.only('creates expected JS files', function (done) {
73+
// helpers.mockPrompt(angular, mockPrompts);
74+
//
75+
// angular.run({}, function() {
76+
// helpers.assertFile([].concat(expected, [
77+
// appPath + '/scripts/app.js',
78+
// appPath + '/scripts/controllers/main.js',
79+
// 'test/spec/controllers/main.js'
80+
// ]));
81+
// done();
82+
// });
83+
// });
84+
//
85+
// it('creates CoffeeScript files', function (done) {
86+
// helpers.mockPrompt(angular, mockPrompts);
87+
//
88+
// angular.env.options.coffee = true;
89+
// angular.run([], function () {
90+
// helpers.assertFile([].concat(expected, [
91+
// appPath + '/scripts/app.coffee',
92+
// appPath + '/scripts/controllers/main.coffee',
93+
// 'test/spec/controllers/main.coffee'
94+
// ]));
95+
// done();
96+
// });
97+
// });
98+
//
99+
// /**
100+
// * Generic test function that can be used to cover the scenarios where a generator is creating both a source file
101+
// * and a test file. The function will run the respective generator, and then check for the existence of the two
102+
// * generated files. A RegExp check is done on each file, checking for the generated content with a pattern.
103+
// *
104+
// * The number of parameters is quite huge due to the many options in which the generated files differ,
105+
// * e.g. Services start with an upper case letter, whereas filters, directives or constants start with a lower case
106+
// * letter.
107+
// *
108+
// * The generated items all use the dummy name 'foo'.
109+
// *
110+
// * @param generatorType The type of generator to run, e.g. 'filter'.
111+
// * @param specType The type of the generated spec file, e.g. 'service' - all service types (constant, value, ...)
112+
// * use the same Service spec template.
113+
// * @param targetDirectory The directory into which the files are generated, e.g. 'directives' - this will be
114+
// * located under 'customAppPath/scripts' for the sources and 'test/spec' for the tests.
115+
// * @param scriptNameFn The function used to create the name of the created item, e.g. _.classify to generate 'Foo',
116+
// * or _.camelize to generate 'foo'.
117+
// * @param specNameFn Same as scriptNameFn, but for the describe text used in the Spec file. Some generators use
118+
// * _.classify, others use _.camelize.
119+
// * @param suffix An optional suffix to be appended to the generated item name, e.g. 'Ctrl' for controllers, which
120+
// * will generate 'FooCtrl'.
121+
// * @param done The done function.
122+
// */
123+
// function generatorTest(generatorType, specType, targetDirectory, scriptNameFn, specNameFn, suffix, done) {
124+
// var angularGenerator;
125+
// var name = 'foo';
126+
// var deps = [path.join('../..', generatorType)];
127+
// angularGenerator = helpers.createGenerator('angular:' + generatorType, deps, [name], genOptions);
128+
//
129+
// helpers.mockPrompt(angular, mockPrompts);
130+
// angular.run([], function () {
131+
// angularGenerator.run([], function () {
132+
// assert.fileContent([
133+
// [
134+
// path.join(appPath + '/scripts', targetDirectory, name + '.js'),
135+
// new RegExp(
136+
// generatorType + '\\(\'' + scriptNameFn(name) + suffix + '\'',
137+
// 'g'
138+
// )
139+
// ]
140+
// ]);
141+
// done();
142+
// });
143+
// });
144+
// }
145+
//
146+
// describe('Controller', function () {
147+
// it('should generate a new controller', function (done) {
148+
// generatorTest('controller', 'controller', 'controllers', _.classify, _.classify, 'Ctrl', done);
149+
// });
150+
// });
151+
//
152+
// describe('Directive', function () {
153+
// it('should generate a new directive', function (done) {
154+
// generatorTest('directive', 'directive', 'directives', _.camelize, _.camelize, '', done);
155+
// });
156+
// });
157+
//
158+
// describe('Filter', function () {
159+
// it('should generate a new filter', function (done) {
160+
// generatorTest('filter', 'filter', 'filters', _.camelize, _.camelize, '', done);
161+
// });
162+
// });
163+
//
164+
// describe('Service', function () {
165+
// function serviceTest (generatorType, nameFn, done) {
166+
// generatorTest(generatorType, 'service', 'services', nameFn, nameFn, '', done);
167+
// }
168+
//
169+
// ['constant', 'factory', 'provider', 'value'].forEach(function(t) {
170+
// it('should generate a new ' + t, function (done) {
171+
// serviceTest(t, _.camelize, done);
172+
// });
173+
// });
174+
//
175+
//
176+
// it('should generate a new service', function (done) {
177+
// serviceTest('service', _.capitalize, done);
178+
// });
179+
// });
180+
//
181+
// describe('View', function () {
182+
// it('should generate a new view', function (done) {
183+
// var angularView;
184+
// var deps = ['../../view'];
185+
// angularView = helpers.createGenerator('angular:view', deps, ['foo'], genOptions);
186+
//
187+
// helpers.mockPrompt(angular, mockPrompts);
188+
// angular.run([], function () {
189+
// angularView.run([], function () {
190+
// helpers.assertFile([appPath + '/views/foo.html']);
191+
// done();
192+
// });
193+
// });
194+
// });
195+
//
196+
// it('should generate a new view in subdirectories', function (done) {
197+
// var angularView;
198+
// var deps = ['../../view'];
199+
// angularView = helpers.createGenerator('angular:view', deps, ['foo/bar'], genOptions);
200+
//
201+
// helpers.mockPrompt(angular, mockPrompts);
202+
// angular.run([], function () {
203+
// angularView.run([], function () {
204+
// helpers.assertFile([appPath + '/views/foo/bar.html']);
205+
// done();
206+
// });
207+
// });
208+
// });
209+
// });
210+
// });

0 commit comments

Comments
 (0)