Skip to content

Commit 53417c0

Browse files
Charles Lydinghansl
Charles Lyding
authored andcommitted
test: convert acceptance tests to jasmine
1 parent f78460d commit 53417c0

16 files changed

+765
-834
lines changed

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@
107107
"@angular/compiler": "^4.0.0",
108108
"@angular/compiler-cli": "^4.0.0",
109109
"@angular/core": "^4.0.0",
110-
"@types/chai": "^3.4.32",
111110
"@types/chalk": "^0.4.28",
112111
"@types/common-tags": "^1.2.4",
113112
"@types/denodeify": "^1.2.29",
114113
"@types/express": "^4.0.32",
115114
"@types/fs-extra": "~3.0.2",
116115
"@types/glob": "^5.0.29",
117-
"@types/jasmine": "~2.2.0",
116+
"@types/jasmine": "2.5.45",
118117
"@types/lodash": "4.14.50",
119118
"@types/minimist": "^1.2.0",
120119
"@types/mock-fs": "^3.6.30",
@@ -123,26 +122,23 @@
123122
"@types/semver": "^5.3.30",
124123
"@types/source-map": "^0.5.0",
125124
"@types/webpack": "^2.2.15",
126-
"chai": "^3.5.0",
127125
"conventional-changelog": "^1.1.0",
128126
"dtsgenerator": "^0.9.1",
129127
"eslint": "^3.11.0",
130128
"express": "^4.14.0",
131-
"jasmine": "^2.4.1",
132-
"jasmine-spec-reporter": "^3.2.0",
129+
"jasmine": "^2.6.0",
130+
"jasmine-spec-reporter": "^4.1.0",
133131
"minimist": "^1.2.0",
134-
"mocha": "^3.2.0",
135132
"mock-fs": "^4.0.0",
136133
"npm-run": "^4.1.0",
137134
"npm-run-all": "^4.0.0",
138-
"object-assign": "^4.0.1",
139135
"request": "^2.74.0",
140136
"resolve-bin": "^0.4.0",
141137
"rewire": "^2.5.1",
142138
"spdx-satisfies": "^0.1.3",
143139
"through": "^2.3.6",
144140
"tree-kill": "^1.0.0",
145-
"ts-node": "^2.0.0",
141+
"ts-node": "^3.0.6",
146142
"tslint": "^5.1.0"
147143
},
148144
"optionalDependencies": {

tests/acceptance/destroy.spec.ts

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
import { expect } from 'chai';
1+
import { ng, setupProject } from '../helpers';
22

3-
const ng = require('../helpers/ng');
4-
const tmp = require('../helpers/tmp');
5-
const SilentError = require('silent-error');
3+
describe('Acceptance: ng destroy', () => {
4+
setupProject();
65

7-
describe('Acceptance: ng destroy', function () {
8-
beforeEach(function () {
9-
this.timeout(10000);
10-
return tmp.setup('./tmp').then(function () {
11-
process.chdir('./tmp');
12-
}).then(function () {
13-
return ng(['new', 'foo', '--skip-install']);
14-
});
6+
it('without args should fail', (done) => {
7+
return ng(['destroy'])
8+
.then(() => done.fail())
9+
.catch(error => {
10+
expect(error.message).toBe('The destroy command is not supported by Angular CLI.');
11+
done();
12+
});
1513
});
1614

17-
afterEach(function () {
18-
return tmp.teardown('./tmp');
19-
});
20-
21-
it('without args should fail', function () {
22-
return ng(['destroy']).then(() => {
23-
throw new SilentError('ng destroy should fail.');
24-
}, (err: any) => {
25-
expect(err.message).to.equal('The destroy command is not supported by Angular CLI.');
26-
});
27-
});
28-
29-
it('with args should fail', function () {
30-
return ng(['destroy', 'something']).then(() => {
31-
throw new SilentError('ng destroy something should fail.');
32-
}, (err: any) => {
33-
expect(err.message).to.equal('The destroy command is not supported by Angular CLI.');
34-
});
15+
it('with args should fail', (done) => {
16+
return ng(['destroy', 'something'])
17+
.then(() => done.fail())
18+
.catch(error => {
19+
expect(error.message).toBe('The destroy command is not supported by Angular CLI.');
20+
done();
21+
});
3522
});
3623
});

tests/acceptance/dynamic-path-parser.spec.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { expect } from 'chai';
21
import * as path from 'path';
32
import { dynamicPathParser } from '@angular/cli/utilities/dynamic-path-parser';
43
import mockFs = require('mock-fs');
@@ -47,8 +46,8 @@ describe('dynamic path parser', () => {
4746
dryRun: false
4847
};
4948
const result = dynamicPathParser(options);
50-
expect(result.dir).to.equal(appDir);
51-
expect(result.name).to.equal(entityName);
49+
expect(result.dir).toBe(appDir);
50+
expect(result.name).toBe(entityName);
5251
});
5352

5453
it('parse from proj src dir', () => {
@@ -60,8 +59,8 @@ describe('dynamic path parser', () => {
6059
dryRun: false
6160
};
6261
const result = dynamicPathParser(options);
63-
expect(result.dir).to.equal(appDir);
64-
expect(result.name).to.equal(entityName);
62+
expect(result.dir).toBe(appDir);
63+
expect(result.name).toBe(entityName);
6564
});
6665

6766
it(`parse from proj src${path.sep}client dir`, () => {
@@ -73,8 +72,8 @@ describe('dynamic path parser', () => {
7372
dryRun: false
7473
};
7574
const result = dynamicPathParser(options);
76-
expect(result.dir).to.equal(appDir);
77-
expect(result.name).to.equal(entityName);
75+
expect(result.dir).toBe(appDir);
76+
expect(result.name).toBe(entityName);
7877
});
7978

8079
it(`parse from proj src${path.sep}client${path.sep}app dir`, () => {
@@ -86,8 +85,8 @@ describe('dynamic path parser', () => {
8685
dryRun: false
8786
};
8887
const result = dynamicPathParser(options);
89-
expect(result.dir).to.equal(appDir);
90-
expect(result.name).to.equal(entityName);
88+
expect(result.dir).toBe(appDir);
89+
expect(result.name).toBe(entityName);
9190
});
9291

9392
it(`parse from proj src${path.sep}client${path.sep}app${path.sep}child-dir`, () => {
@@ -111,8 +110,8 @@ describe('dynamic path parser', () => {
111110
dryRun: false
112111
};
113112
const result = dynamicPathParser(options);
114-
expect(result.dir).to.equal(`${appDir}${path.sep}child-dir`);
115-
expect(result.name).to.equal(entityName);
113+
expect(result.dir).toBe(`${appDir}${path.sep}child-dir`);
114+
expect(result.name).toBe(entityName);
116115
});
117116

118117
// tslint:disable-next-line:max-line-length
@@ -136,8 +135,8 @@ describe('dynamic path parser', () => {
136135
dryRun: false
137136
};
138137
const result = dynamicPathParser(options);
139-
expect(result.dir).to.equal(appDir);
140-
expect(result.name).to.equal(entityName);
138+
expect(result.dir).toBe(appDir);
139+
expect(result.name).toBe(entityName);
141140
});
142141

143142
// tslint:disable-next-line:max-line-length
@@ -164,8 +163,8 @@ describe('dynamic path parser', () => {
164163
dryRun: false
165164
};
166165
const result = dynamicPathParser(options);
167-
expect(result.dir).to.equal(`${appDir}${path.sep}child-dir`);
168-
expect(result.name).to.equal(entityName);
166+
expect(result.dir).toBe(`${appDir}${path.sep}child-dir`);
167+
expect(result.name).toBe(entityName);
169168
});
170169

171170
it('auto look for dirs with a "+" when not specified', () => {
@@ -186,8 +185,8 @@ describe('dynamic path parser', () => {
186185
dryRun: false
187186
};
188187
const result = dynamicPathParser(options);
189-
expect(result.dir).to.equal(`${appDir}${path.sep}+my-route`);
190-
expect(result.name).to.equal(entityName);
188+
expect(result.dir).toBe(`${appDir}${path.sep}+my-route`);
189+
expect(result.name).toBe(entityName);
191190
});
192191

193192
it('create new dirs as dasherized', () => {
@@ -199,7 +198,7 @@ describe('dynamic path parser', () => {
199198
dryRun: false
200199
};
201200
const result = dynamicPathParser(options);
202-
expect(result.dir).to.equal(`${appDir}${path.sep}new-dir`);
203-
expect(result.name).to.equal(entityName);
201+
expect(result.dir).toBe(`${appDir}${path.sep}new-dir`);
202+
expect(result.name).toBe(entityName);
204203
});
205204
});
Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
11
import * as fs from 'fs-extra';
2-
import { expect } from 'chai';
32
import * as path from 'path';
4-
5-
const ng = require('../helpers/ng');
6-
const tmp = require('../helpers/tmp');
3+
import { ng, setupProject } from '../helpers';
74

85
const root = process.cwd();
96

107
const testPath = path.join(root, 'tmp', 'foo', 'src', 'app');
118

12-
describe('Acceptance: ng generate class', function () {
13-
beforeEach(function () {
14-
this.timeout(10000);
15-
return tmp.setup('./tmp').then(function () {
16-
process.chdir('./tmp');
17-
}).then(function () {
18-
return ng(['new', 'foo', '--skip-install']);
19-
});
20-
});
21-
22-
afterEach(function () {
23-
return tmp.teardown('./tmp');
24-
});
9+
describe('Acceptance: ng generate class', () => {
10+
setupProject();
2511

26-
it('ng generate class my-class', function () {
12+
it('ng generate class my-class', (done) => {
2713
return ng(['generate', 'class', 'my-class']).then(() => {
28-
expect(fs.pathExistsSync(path.join(testPath, 'my-class.ts'))).to.equal(true);
29-
expect(fs.pathExistsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(false);
30-
});
14+
expect(fs.pathExistsSync(path.join(testPath, 'my-class.ts'))).toBe(true);
15+
expect(fs.pathExistsSync(path.join(testPath, 'my-class.spec.ts'))).toBe(false);
16+
})
17+
.then(done, done.fail);
3118
});
3219

33-
it('ng generate class my-class --no-spec', function () {
20+
it('ng generate class my-class --no-spec', (done) => {
3421
return ng(['generate', 'class', 'my-class', '--no-spec']).then(() => {
35-
expect(fs.pathExistsSync(path.join(testPath, 'my-class.ts'))).to.equal(true);
36-
expect(fs.pathExistsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(false);
37-
});
22+
expect(fs.pathExistsSync(path.join(testPath, 'my-class.ts'))).toBe(true);
23+
expect(fs.pathExistsSync(path.join(testPath, 'my-class.spec.ts'))).toBe(false);
24+
})
25+
.then(done, done.fail);
3826
});
3927

40-
it('ng generate class my-class.model', function () {
28+
it('ng generate class my-class.model', (done) => {
4129
return ng(['generate', 'class', 'my-class.model']).then(() => {
42-
expect(fs.pathExistsSync(path.join(testPath, 'my-class.model.ts'))).to.equal(true);
43-
});
30+
expect(fs.pathExistsSync(path.join(testPath, 'my-class.model.ts'))).toBe(true);
31+
})
32+
.then(done, done.fail);
4433
});
4534
});

0 commit comments

Comments
 (0)