Skip to content

Commit 2f4ff82

Browse files
committed
test: update e2e tests
1 parent ca4a510 commit 2f4ff82

File tree

7 files changed

+40
-18
lines changed

7 files changed

+40
-18
lines changed

tests/acceptance/generate-component.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var tmp = require('../helpers/tmp');
1010
var root = process.cwd();
1111
var conf = require('ember-cli/tests/helpers/conf');
1212
var Promise = require('ember-cli/lib/ext/promise');
13+
var SilentError = require('silent-error');
1314

1415
describe('Acceptance: ng generate component', function () {
1516
before(conf.setup);
@@ -134,8 +135,9 @@ describe('Acceptance: ng generate component', function () {
134135

135136
it('ng generate component ..' + path.sep + 'my-comp from root dir will fail', () => {
136137
return ng(['generate', 'component', '..' + path.sep + 'my-comp']).then(() => {
137-
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', '..', 'my-comp', 'my-comp.component.ts');
138-
expect(existsSync(testPath)).to.equal(false);
138+
throw new SilentError(`ng generate component ..${path.sep}my-comp from root dir should fail.`);
139+
}, (err) => {
140+
expect(err).to.equal(`Invalid path: "..${path.sep}my-comp" cannot be above the "src${path.sep}client${path.sep}app" directory`);
139141
});
140142
});
141143

tests/acceptance/generate-directive.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var tmp = require('../helpers/tmp');
1010
var root = process.cwd();
1111
var conf = require('ember-cli/tests/helpers/conf');
1212
var Promise = require('ember-cli/lib/ext/promise');
13+
var SilentError = require('silent-error');
1314

1415
describe('Acceptance: ng generate directive', function () {
1516
before(conf.setup);
@@ -144,8 +145,9 @@ describe('Acceptance: ng generate directive', function () {
144145

145146
it('ng generate directive ..' + path.sep + 'my-dir from root dir will fail', () => {
146147
return ng(['generate', 'directive', '..' + path.sep + 'my-dir']).then(() => {
147-
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', '..', 'my-dir', 'my-dir.directive.ts');
148-
expect(existsSync(testPath)).to.equal(false);
148+
throw new SilentError(`ng generate directive ..${path.sep}my-dir from root dir should fail.`);
149+
}, (err) => {
150+
expect(err).to.equal(`Invalid path: "..${path.sep}my-dir" cannot be above the "src${path.sep}client${path.sep}app" directory`);
149151
});
150152
});
151153
});

tests/acceptance/generate-pipe.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var tmp = require('../helpers/tmp');
1010
var root = process.cwd();
1111
var conf = require('ember-cli/tests/helpers/conf');
1212
var Promise = require('ember-cli/lib/ext/promise');
13+
var SilentError = require('silent-error');
1314

1415
describe('Acceptance: ng generate pipe', function () {
1516
before(conf.setup);
@@ -133,8 +134,9 @@ describe('Acceptance: ng generate pipe', function () {
133134

134135
it('ng generate pipe ..' + path.sep + 'my-pipe from root dir will fail', () => {
135136
return ng(['generate', 'pipe', '..' + path.sep + 'my-pipe']).then(() => {
136-
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', '..', 'my-pipe.pipe.ts');
137-
expect(existsSync(testPath)).to.equal(false);
137+
throw new SilentError(`ng generate pipe ..${path.sep}my-pipe from root dir should fail.`);
138+
}, (err) => {
139+
expect(err).to.equal(`Invalid path: "..${path.sep}my-pipe" cannot be above the "src${path.sep}client${path.sep}app" directory`);
138140
});
139141
});
140142
});

tests/acceptance/generate-service.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var tmp = require('../helpers/tmp');
1010
var root = process.cwd();
1111
var conf = require('ember-cli/tests/helpers/conf');
1212
var Promise = require('ember-cli/lib/ext/promise');
13+
var SilentError = require('silent-error');
1314

1415
describe('Acceptance: ng generate service', function () {
1516
before(conf.setup);
@@ -136,8 +137,9 @@ describe('Acceptance: ng generate service', function () {
136137

137138
it('ng generate service ..' + path.sep + 'my-svc from root dir will fail', () => {
138139
return ng(['generate', 'service', '..' + path.sep + 'my-svc']).then(() => {
139-
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', '..', 'my-svc.service.ts');
140-
expect(existsSync(testPath)).to.equal(false);
140+
throw new SilentError(`ng generate service ..${path.sep}my-svc from root dir should fail.`);
141+
}, (err) => {
142+
expect(err).to.equal(`Invalid path: "..${path.sep}my-svc" cannot be above the "src${path.sep}client${path.sep}app" directory`);
141143
});
142144
});
143145
});

tests/acceptance/github-pages-deploy.spec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var chai = require('chai');
1111
var sinon = require('sinon');
1212
var ExecStub = require('../helpers/exec-stub');
1313
var https = require('https');
14+
var SilentError = require('silent-error');
1415

1516
const expect = chai.expect;
1617
const fsReadFile = Promise.denodeify(fs.readFile);
@@ -58,7 +59,12 @@ describe('Acceptance: ng github-pages:deploy', function() {
5859
it('should fail with uncommited changes', function() {
5960
execStub.addExecSuccess('git status --porcelain', 'M dir/file.ext');
6061
return ng(['github-pages:deploy', '--skip-build'])
61-
.then((ret) => expect(ret).to.equal(1))
62+
.then(() => {
63+
throw new SilentError('Should fail with uncommited changes but passing.');
64+
}, (ret) => {
65+
expect(ret.name).to.equal('SilentError');
66+
expect(ret.isSilentError).to.equal(true);
67+
});
6268
});
6369

6470
it('should deploy with defaults to existing remote', function() {
@@ -226,7 +232,12 @@ describe('Acceptance: ng github-pages:deploy', function() {
226232

227233
return ng(['github-pages:deploy', '--skip-build', `--gh-token=${token}`,
228234
`--gh-username=${username}`])
229-
.then((ret) => expect(ret).to.equal(1))
235+
.then(() => {
236+
throw new SilentError('Should not pass the deploy.');
237+
}, (ret) => {
238+
expect(ret.name).to.equal('SilentError');
239+
expect(ret.isSilentError).to.equal(true);
240+
})
230241
.then(() => httpsStub.restore());
231242
});
232243
});

tests/acceptance/new.spec.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var root = process.cwd();
1313
var util = require('util');
1414
var conf = require('ember-cli/tests/helpers/conf');
1515
var EOL = require('os').EOL;
16+
var SilentError = require('silent-error');
1617

1718
describe('Acceptance: ng new', function () {
1819
before(conf.setup);
@@ -64,12 +65,12 @@ describe('Acceptance: ng new', function () {
6465
return ng(['new', 'foo', '--skip-npm', '--skip-bower']).then(confirmBlueprinted);
6566
});
6667

67-
it('ng new with empty app name doesnt throw exception', function () {
68-
return ng(['new', '']);
68+
it('ng new with empty app does throw exception', function () {
69+
expect(ng(['new', ''])).to.throw;
6970
});
7071

71-
it('ng new without app name doesnt throw exception', function () {
72-
return ng(['new']);
72+
it('ng new without app name does throw exception', function () {
73+
expect(ng(['new', ''])).to.throw;
7374
});
7475

7576
it('ng new with app name creates new directory and has a dasherized package name', function () {
@@ -84,9 +85,11 @@ describe('Acceptance: ng new', function () {
8485
it('Cannot run ng new, inside of ember-cli project', function () {
8586
return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git'])
8687
.then(function () {
87-
return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']).then(function () {
88+
return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']).then(() => {
89+
throw new SilentError('Cannot run ng new, inside of ember-cli project should fail.');
90+
}, () => {
8891
expect(!existsSync('foo'));
89-
});
92+
})
9093
})
9194
.then(confirmBlueprinted);
9295
});

tests/e2e/e2e_workflow.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('Basic end-to-end Workflow', function () {
6868
var envContent = fs.readFileSync(envPath, { encoding: 'utf8' });
6969
expect(envContent).to.include('production:true');
7070
// Also does not create new things in GIT.
71-
expect(sh.exec('git status --porcelain').output).to.be.equal('');
71+
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
7272
});
7373

7474
it('Can run `ng build` in created project', function () {
@@ -80,7 +80,7 @@ describe('Basic end-to-end Workflow', function () {
8080
})
8181
.then(function () {
8282
// Also does not create new things in GIT.
83-
expect(sh.exec('git status --porcelain').output).to.be.equal('');
83+
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
8484
})
8585
.catch(() => {
8686
throw new Error('Build failed.');

0 commit comments

Comments
 (0)