|
| 1 | +/*global describe, beforeEach, it*/ |
| 2 | +'use strict'; |
| 3 | + |
| 4 | +var path = require('path'); |
| 5 | +var helpers = require('yeoman-generator').test; |
| 6 | +var assert = require('assert'); |
| 7 | + |
| 8 | +var expected = [ |
| 9 | + |
| 10 | + // Project files |
| 11 | + '.jshintrc', |
| 12 | + '.editorconfig', |
| 13 | + '.htaccess', |
| 14 | + |
| 15 | + // Bower |
| 16 | + '.bowerrc', |
| 17 | + 'bower.json', |
| 18 | + |
| 19 | + // Pkg |
| 20 | + 'package.json', |
| 21 | + |
| 22 | + // Git |
| 23 | + '.gitattributes', |
| 24 | + '.gitignore', |
| 25 | + |
| 26 | + // Travis |
| 27 | + '.travis.yml', |
| 28 | + |
| 29 | + // Robots |
| 30 | + 'robots.txt', |
| 31 | + |
| 32 | + // HTML |
| 33 | + 'templates/header.html', |
| 34 | + 'templates/index.html', |
| 35 | + 'templates/footer.html', |
| 36 | + 'pages.json', |
| 37 | + |
| 38 | + // Karma |
| 39 | + 'karma.conf.js', |
| 40 | + |
| 41 | + // Humans |
| 42 | + 'humans.txt', |
| 43 | + |
| 44 | + // Grunt |
| 45 | + 'Gruntfile.js', |
| 46 | + 'tasks/config.js', |
| 47 | + 'tasks/options/clean.js', |
| 48 | + 'tasks/options/concat.js', |
| 49 | + 'tasks/options/connect.js', |
| 50 | + 'tasks/options/copy.js', |
| 51 | + 'tasks/options/imagemin.js', |
| 52 | + 'tasks/options/jshint.js', |
| 53 | + 'tasks/options/karma.js', |
| 54 | + 'tasks/options/modernizr.js', |
| 55 | + 'tasks/options/replace.js', |
| 56 | + 'tasks/options/requirejs.js', |
| 57 | + 'tasks/options/sass.js', |
| 58 | + 'tasks/options/watch.js', |
| 59 | + |
| 60 | + // Javascript |
| 61 | + 'js/modules/module.js', |
| 62 | + 'js/plugins/console.js', |
| 63 | + 'js/config.js', |
| 64 | + 'js/main.js', |
| 65 | + |
| 66 | + // Authors |
| 67 | + 'AUTHORS', |
| 68 | + |
| 69 | + // Ico |
| 70 | + 'apple-touch-icon-precomposed.png', |
| 71 | + 'favicon.ico', |
| 72 | + |
| 73 | + // Contribuiting |
| 74 | + 'CONTRIBUTING.md', |
| 75 | + |
| 76 | + // Cossdomain |
| 77 | + 'crossdomain.xml', |
| 78 | + |
| 79 | + // 404 |
| 80 | + '404.html', |
| 81 | + |
| 82 | + // Test |
| 83 | + 'test/specs/example.spec.js', |
| 84 | + 'test/spec.js', |
| 85 | + 'test/test-main.js' |
| 86 | + |
| 87 | +]; |
| 88 | + |
| 89 | +describe('init generator', function () { |
| 90 | + |
| 91 | + beforeEach(function (done) { |
| 92 | + helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { |
| 93 | + if (err) { |
| 94 | + return done(err); |
| 95 | + } |
| 96 | + |
| 97 | + this.app = helpers.createGenerator('init:app', [ |
| 98 | + '../../app' |
| 99 | + ]); |
| 100 | + done(); |
| 101 | + }.bind(this)); |
| 102 | + }); |
| 103 | + |
| 104 | + it('the generator can be required without throwing', function () { |
| 105 | + // not testing the actual run of generators yet |
| 106 | + var app = require('../app'); |
| 107 | + assert(app !== undefined); |
| 108 | + }); |
| 109 | + |
| 110 | + it('creates expected files for SCSS preprocessor', function (done) { |
| 111 | + |
| 112 | + helpers.mockPrompt(this.app, { |
| 113 | + 'cssPreprocessor': 'Compass' |
| 114 | + }); |
| 115 | + |
| 116 | + var expectedSCSS = [ |
| 117 | + 'scss/main.scss', |
| 118 | + 'scss/elements/_typography.scss', |
| 119 | + 'scss/helpers/_helpers.scss', |
| 120 | + 'scss/helpers/_variables.scss', |
| 121 | + 'scss/media/_print.scss', |
| 122 | + 'scss/modules/_box.scss', |
| 123 | + 'scss/page/_base.scss', |
| 124 | + 'scss/page/_footer.scss', |
| 125 | + 'scss/page/_header.scss', |
| 126 | + 'scss/page/_main.scss' |
| 127 | + ]; |
| 128 | + |
| 129 | + expectedSCSS.concat(expectedSCSS, expected); |
| 130 | + |
| 131 | + this.app.options['skip-install'] = true; |
| 132 | + this.app.run({}, function () { |
| 133 | + helpers.assertFiles(expectedSCSS); |
| 134 | + done(); |
| 135 | + }); |
| 136 | + |
| 137 | + }); |
| 138 | + |
| 139 | + it('creates expected files for LESS preprocessor', function (done) { |
| 140 | + |
| 141 | + helpers.mockPrompt(this.app, { |
| 142 | + 'cssPreprocessor': 'LESS' |
| 143 | + }); |
| 144 | + |
| 145 | + var expectedLESS = [ |
| 146 | + 'less/main.less', |
| 147 | + 'less/elements/_typography.less', |
| 148 | + 'less/helpers/_helpers.less', |
| 149 | + 'less/helpers/_variables.less', |
| 150 | + 'less/media/_print.less', |
| 151 | + 'less/modules/_box.less', |
| 152 | + 'less/page/_base.less', |
| 153 | + 'less/page/_footer.less', |
| 154 | + 'less/page/_header.less', |
| 155 | + 'less/page/_main.less' |
| 156 | + ]; |
| 157 | + |
| 158 | + expectedLESS.concat(expectedLESS, expected); |
| 159 | + |
| 160 | + this.app.options['skip-install'] = true; |
| 161 | + this.app.run({}, function () { |
| 162 | + helpers.assertFiles(expectedLESS); |
| 163 | + done(); |
| 164 | + }); |
| 165 | + |
| 166 | + }); |
| 167 | + |
| 168 | +}); |
0 commit comments