|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var fs = require('fs'); |
| 4 | +var path = require('path'); |
| 5 | +var tmp = require('../helpers/tmp'); |
| 6 | +var chai = require('chai'); |
| 7 | +var expect = chai.expect; |
| 8 | +var conf = require('ember-cli/tests/helpers/conf'); |
| 9 | +var sh = require('shelljs'); |
| 10 | +var ng = require('../helpers/ng'); |
| 11 | +var root = path.join(process.cwd(), 'tmp'); |
| 12 | + |
| 13 | +describe('Basic end-to-end Workflow', function () { |
| 14 | + before(conf.setup); |
| 15 | + |
| 16 | + after(conf.restore); |
| 17 | + |
| 18 | + it('Installs angular-cli correctly', function() { |
| 19 | + this.timeout(300000); |
| 20 | + |
| 21 | + return tmp.setup('./tmp') |
| 22 | + .then(function () { |
| 23 | + process.chdir('./tmp'); |
| 24 | + |
| 25 | + sh.exec('npm i angular-cli -g -C ' + process.cwd(), { silent: true }); |
| 26 | + expect(fs.existsSync(path.join(process.cwd(), 'bin', 'ng'))); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + it('Can create new project using `ng new test-project`', function() { |
| 31 | + this.timeout(300000); |
| 32 | + |
| 33 | + return ng([ |
| 34 | + 'new', |
| 35 | + 'test-project', |
| 36 | + '--silent' |
| 37 | + ]).then(function() { |
| 38 | + expect(fs.existsSync(path.join(root, 'test-project'))); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('Can change current working directory to `test-project`', function() { |
| 43 | + process.chdir(path.join(root, 'test-project')); |
| 44 | + expect(path.basename(process.cwd())).to.equal('test-project'); |
| 45 | + }); |
| 46 | + |
| 47 | + it('Can run `ng build` in created project', function() { |
| 48 | + this.timeout(10000); |
| 49 | + |
| 50 | + return ng([ |
| 51 | + 'build', |
| 52 | + '--silent' |
| 53 | + ]).then(function() { |
| 54 | + expect(fs.existsSync(path.join(process.cwd(), 'dist'))); |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + it('Perform `ng test`', function(done) { |
| 59 | + this.timeout(30000); |
| 60 | + |
| 61 | + return ng([ |
| 62 | + 'test' |
| 63 | + ]).then(function(err) { |
| 64 | + // TODO when `ng test` will be implemented |
| 65 | + //expect(err).to.be.equal(1); |
| 66 | + done(); |
| 67 | + }); |
| 68 | + }); |
| 69 | + |
| 70 | + it('Can create a test component using `ng generate component test-component`', function() { |
| 71 | + return ng([ |
| 72 | + 'generate', |
| 73 | + 'component', |
| 74 | + 'test-component' |
| 75 | + ]).then(function() { |
| 76 | + var componentDir = path.join(process.cwd(), 'src', 'app', 'components', 'test-component'); |
| 77 | + expect(fs.existsSync(componentDir)); |
| 78 | + expect(fs.existsSync(path.join(componentDir, 'test-component.ts'))); |
| 79 | + expect(fs.existsSync(path.join(componentDir, 'test-component.html'))); |
| 80 | + expect(fs.existsSync(path.join(componentDir, 'test-component.css'))); |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + it('Perform `ng test`', function(done) { |
| 85 | + this.timeout(30000); |
| 86 | + |
| 87 | + return ng([ |
| 88 | + 'test' |
| 89 | + ]).then(function(err) { |
| 90 | + // TODO when `ng test` will be implemented |
| 91 | + //expect(err).to.be.equal(1); |
| 92 | + done(); |
| 93 | + }); |
| 94 | + }); |
| 95 | + |
| 96 | + it('Can create a test service using `ng generate service test-service`', function() { |
| 97 | + return ng([ |
| 98 | + 'generate', |
| 99 | + 'service', |
| 100 | + 'test-service' |
| 101 | + ]).then(function() { |
| 102 | + var serviceDir = path.join(process.cwd(), 'src', 'app', 'services', 'test-service'); |
| 103 | + expect(fs.existsSync(serviceDir)); |
| 104 | + expect(fs.existsSync(path.join(serviceDir, 'test-service.ts'))); |
| 105 | + expect(fs.existsSync(path.join(serviceDir, 'test-service.spec.ts'))); |
| 106 | + }); |
| 107 | + }); |
| 108 | + |
| 109 | + it('Perform `ng test`', function(done) { |
| 110 | + this.timeout(30000); |
| 111 | + |
| 112 | + return ng([ |
| 113 | + 'test' |
| 114 | + ]).then(function(err) { |
| 115 | + // TODO when `ng test` will be implemented |
| 116 | + //expect(err).to.be.equal(1); |
| 117 | + done(); |
| 118 | + }); |
| 119 | + }); |
| 120 | + |
| 121 | + it('Can create a test pipe using `ng generate pipe test-pipe`', function() { |
| 122 | + return ng([ |
| 123 | + 'generate', |
| 124 | + 'pipe', |
| 125 | + 'test-pipe' |
| 126 | + ]).then(function() { |
| 127 | + var pipeDir = path.join(process.cwd(), 'src', 'app', 'pipes', 'test-pipe'); |
| 128 | + expect(fs.existsSync(pipeDir)); |
| 129 | + expect(fs.existsSync(path.join(pipeDir, 'test-pipe.ts'))); |
| 130 | + expect(fs.existsSync(path.join(pipeDir, 'test-pipe.spec.ts'))); |
| 131 | + }); |
| 132 | + }); |
| 133 | + |
| 134 | + it('Perform `ng test`', function(done) { |
| 135 | + this.timeout(300000); |
| 136 | + |
| 137 | + return ng([ |
| 138 | + 'test' |
| 139 | + ]).then(function(err) { |
| 140 | + // TODO when `ng test` will be implemented |
| 141 | + //expect(err).to.be.equal(1); |
| 142 | + // Clean `tmp` folder |
| 143 | + |
| 144 | + process.chdir(path.resolve(root, '..')); |
| 145 | + sh.rm('-rf', './tmp'); // tmp.teardown takes too long |
| 146 | + |
| 147 | + done(); |
| 148 | + }); |
| 149 | + }); |
| 150 | + |
| 151 | +}); |
0 commit comments