fix(zone.js): add issue numbers of @types/jasmine to the test cases (#34625)

Some cases will still need to use `spy as any` cast, because `@types/jasmine` have some issues,
1. The issue jasmine doesn't handle optional method properties, https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
2. The issue jasmine doesn't handle overload method correctly, https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42455

PR Close #34625
This commit is contained in:
JiaLiPassion
2020-03-31 00:22:25 +09:00
committed by Kara Erickson
parent b28a5f6eef
commit 421b6a97d6
22 changed files with 5993 additions and 5745 deletions

View File

@ -47,7 +47,7 @@ describe('CachedFileSystem', () => {
let lstatSpy: jasmine.Spy;
beforeEach(() => {
// For most of the tests the files are not symbolic links.
lstatSpy = spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
lstatSpy = spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
});
it('should call delegate if not in cache', () => {
@ -93,7 +93,7 @@ describe('CachedFileSystem', () => {
describe('invalidateCaches()', () => {
it('should call the delegate `readFile()` if the path for the cached file has been invalidated',
() => {
spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
const spy = spyOn(delegate, 'readFile').and.returnValue('Some contents');
fs.readFile(abcPath); // Call once to fill the cache
spy.calls.reset();
@ -230,7 +230,7 @@ describe('CachedFileSystem', () => {
describe('moveFile()', () => {
beforeEach(() => {
// `moveFile()` relies upon `readFile` which calls through to `lstat()`, so stub it out.
spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
});
it('should call delegate', () => {

View File

@ -69,6 +69,7 @@ describe('NodeJSFileSystem', () => {
const result = fs.readdir(abcPath);
expect(result).toEqual([relativeFrom('x'), relativeFrom('y/z')]);
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
expect(spy as any).toHaveBeenCalledWith(abcPath);
});
});
@ -90,6 +91,7 @@ describe('NodeJSFileSystem', () => {
const result = fs.stat(abcPath);
expect(result).toBe(stats);
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
expect(spy as any).toHaveBeenCalledWith(abcPath);
});
});
@ -173,12 +175,14 @@ describe('NodeJSFileSystem', () => {
}
return false;
});
spyOn(fs, 'stat').and.returnValue({ isDirectory: () => true } as any);
const mkdirSyncSpy = spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
if (path === abcPath) {
throw new Error('It exists already. Supposedly.');
}
}) as any);
spyOn(fs, 'stat').and.returnValue({isDirectory: () => true} as any);
const mkdirSyncSpy =
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
if (path === abcPath) {
throw new Error(
'It exists already. Supposedly.');
}
}) as any);
fs.ensureDir(abcPath);
expect(mkdirSyncSpy).toHaveBeenCalledTimes(3);
@ -188,11 +192,12 @@ describe('NodeJSFileSystem', () => {
it('should fail if creating the directory throws and the directory does not exist', () => {
spyOn(fs, 'exists').and.returnValue(false);
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
if (path === abcPath) {
throw new Error('Unable to create directory (for whatever reason).');
}
}) as any);
spyOn(realFs, 'mkdirSync')
.and.callFake(((path: string) => {
if (path === abcPath) {
throw new Error('Unable to create directory (for whatever reason).');
}
}) as any);
expect(() => fs.ensureDir(abcPath))
.toThrowError('Unable to create directory (for whatever reason).');
@ -212,12 +217,12 @@ describe('NodeJSFileSystem', () => {
}
return false;
});
spyOn(fs, 'stat').and.returnValue({ isDirectory: isDirectorySpy } as any);
spyOn(fs, 'stat').and.returnValue({isDirectory: isDirectorySpy} as any);
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
if (path === abcPath) {
throw new Error('It exists already. Supposedly.');
}
}) as any);
if (path === abcPath) {
throw new Error('It exists already. Supposedly.');
}
}) as any);
expect(() => fs.ensureDir(abcPath)).toThrowError('It exists already. Supposedly.');
expect(isDirectorySpy).toHaveBeenCalledTimes(1);