|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var fs = require('fs'), |
| 4 | + path = require('path'); |
| 5 | + |
| 6 | +var helper = require('../helpers/helper'); |
| 7 | + |
| 8 | +describe('The Angularity init task should correctly initialise all the files needed for a new project.', function () { |
| 9 | + |
| 10 | + afterEach(function(){ |
| 11 | + helper.cleanTestTemp(); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should correctly initialise a project with a custom name.', function (done) { |
| 15 | + var initTempPath = helper.resolveTestTempPath('init-temp'); |
| 16 | + process.chdir(initTempPath); |
| 17 | + |
| 18 | + var customName = 'todo'; |
| 19 | + |
| 20 | + helper.runAngularity(['init', '-n', customName]) |
| 21 | + .then(function (result) { |
| 22 | + |
| 23 | + //'init:bower' |
| 24 | + var bowerFile = path.join(initTempPath, 'bower.json'); |
| 25 | + expect(fs.existsSync(bowerFile)).toBe(true); |
| 26 | + |
| 27 | + var bowerFileContent = require(bowerFile); |
| 28 | + expect(bowerFileContent.name).toBe(customName); |
| 29 | + expect(bowerFileContent.version).toBe('0.0.0'); |
| 30 | + expect(bowerFileContent.private).toEqual(true); |
| 31 | + |
| 32 | + //'init:npm' |
| 33 | + expect(fs.existsSync(path.join(initTempPath, 'package.json'))).toBe(true); |
| 34 | + |
| 35 | + //'init:karma' |
| 36 | + expect(fs.existsSync(path.join(initTempPath, 'karma.conf.js'))).toBe(true); |
| 37 | + |
| 38 | + //'init:angularity' |
| 39 | + expect(fs.existsSync(path.join(initTempPath, 'angularity.json'))).toBe(true); |
| 40 | + |
| 41 | + //'init:jshint' |
| 42 | + expect(fs.existsSync(path.join(initTempPath, '.jshintrc'))).toBe(true); |
| 43 | + |
| 44 | + //'init:gitignore' |
| 45 | + expect(fs.existsSync(path.join(initTempPath, '.gitignore'))).toBe(true); |
| 46 | + |
| 47 | + //'init:composition' |
| 48 | + var appPath = path.join(initTempPath, 'app'); |
| 49 | + expect(fs.existsSync(path.join(appPath, 'index.html'))).toBe(true); |
| 50 | + expect(fs.existsSync(path.join(appPath, 'index.js'))).toBe(true); |
| 51 | + expect(fs.existsSync(path.join(appPath, 'index.scss'))).toBe(true); |
| 52 | + |
| 53 | + done(); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | +}); |
0 commit comments