Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 6388b31

Browse files
committed
chore(): make all tests pass with jest.
1 parent fd990ed commit 6388b31

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"@types/fs-extra": "^0.0.33",
7878
"@types/glob": "^5.0.30",
7979
"@types/jasmine": "^2.2.33",
80+
"@types/jest": "^16.0.1",
8081
"@types/mock-fs": "^3.6.29",
8182
"@types/node": "^6.0.38",
8283
"@types/node-sass": "^0.0.29",

src/build.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/*import { BuildContext } from './util/interfaces';
1+
import { BuildContext } from './util/interfaces';
22

33
import * as helpers from './util/helpers';
4+
import * as clean from './clean';
45
import * as build from './build';
56
import * as bundle from './bundle';
67
import * as copy from './copy';
@@ -12,6 +13,7 @@ import * as transpile from './transpile';
1213

1314
describe('build', () => {
1415
beforeEach(() => {
16+
spyOn(clean, 'clean');
1517
spyOn(helpers, 'readFileAsync').and.returnValue(Promise.resolve());
1618
spyOn(copy, 'copy').and.returnValue(Promise.resolve());
1719
spyOn(ngc, 'ngc').and.returnValue(Promise.resolve());
@@ -23,7 +25,7 @@ describe('build', () => {
2325
spyOn(transpile, 'transpile').and.returnValue(Promise.resolve());
2426
});
2527

26-
it('should do a prod build', (done: Function) => {
28+
it('should do a prod build', () => {
2729
let context: BuildContext = {
2830
isProd: true,
2931
optimizeJs: true,
@@ -32,7 +34,7 @@ describe('build', () => {
3234
runAot: true
3335
};
3436

35-
build.build(context).then(() => {
37+
return build.build(context).then(() => {
3638
expect(helpers.readFileAsync).toHaveBeenCalled();
3739
expect(copy.copy).toHaveBeenCalled();
3840
expect(ngc.ngc).toHaveBeenCalled();
@@ -43,7 +45,6 @@ describe('build', () => {
4345
expect(lint.lint).toHaveBeenCalled();
4446

4547
expect(transpile.transpile).not.toHaveBeenCalled();
46-
done();
4748
}).catch(err => {
4849
console.log(`err.message: `, err.message);
4950
expect(true).toEqual(false);
@@ -78,4 +79,3 @@ describe('build', () => {
7879
});
7980

8081
});
81-
*/

src/clean.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('clean task', () => {
66
describe('clean', () => {
77
it('should empty the build directory', (done: Function) => {
88
// arrage
9-
spyOn(fs, fs.emptyDirSync.name).and.returnValue('hurray');
9+
spyOn(fs, fs.emptyDirSync.name).and.returnValue('things');
1010
const context = { buildDir: 'something' };
1111

1212
// act
@@ -17,24 +17,22 @@ describe('clean task', () => {
1717
});
1818
});
1919

20-
it('should throw when failing to empty dir', (done: Function) => {
20+
it('should throw when failing to empty dir', async () => {
2121
// arrage
2222
spyOn(fs, fs.emptyDirSync.name).and.throwError('Simulating an error');
2323
const context = { buildDir: 'something' };
2424

2525
// act
2626
let error: Error = null;
2727
try {
28-
clean.clean(context);
28+
await clean.clean(context);
2929
} catch (ex) {
3030
error = ex;
3131
}
3232

3333
// assert
34-
expect(error).toBeTruthy('Error is null');
3534
expect(error instanceof Error).toBe(true, 'Error is not an instance of type Error');
3635
expect(typeof error.message).toBe('string', 'error.message is not a string');
37-
done();
3836
});
3937
});
4038
});

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"noImplicitAny": true,
1010
"types": [
1111
"jasmine",
12-
"node"
12+
"node",
13+
"jest"
1314
]
1415
},
1516
"include": [

0 commit comments

Comments
 (0)