2018-01-26 17:12:46 -05:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as path from 'path';
|
|
|
|
|
|
|
|
import {ReflectorHost} from '../src/reflector_host';
|
|
|
|
|
|
|
|
import {toh} from './test_data';
|
|
|
|
import {MockTypescriptHost} from './test_utils';
|
|
|
|
|
|
|
|
describe('reflector_host_spec', () => {
|
|
|
|
|
|
|
|
// Regression #21811
|
|
|
|
it('should be able to find angular under windows', () => {
|
|
|
|
const originalJoin = path.join;
|
2019-05-22 02:26:05 -04:00
|
|
|
const originalPosixJoin = path.posix.join;
|
|
|
|
let mockHost =
|
2019-08-05 20:13:20 -04:00
|
|
|
new MockTypescriptHost(['/app/main.ts', '/app/parsing-cases.ts'], toh, 'node_modules', {
|
2019-05-22 02:26:05 -04:00
|
|
|
...path,
|
|
|
|
join: (...args: string[]) => originalJoin.apply(path, args),
|
|
|
|
posix:
|
|
|
|
{...path.posix, join: (...args: string[]) => originalPosixJoin.apply(path, args)}
|
|
|
|
});
|
2019-08-05 20:13:20 -04:00
|
|
|
const reflectorHost = new ReflectorHost(() => undefined as any, mockHost);
|
2018-01-26 17:12:46 -05:00
|
|
|
|
2019-04-25 09:07:39 -04:00
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
// If we call this in Windows it will cause a 'Maximum call stack size exceeded error'
|
|
|
|
// Because we are spying on the same function that we are call faking
|
|
|
|
spyOn(path, 'join').and.callFake((...args: string[]) => { return path.win32.join(...args); });
|
|
|
|
}
|
|
|
|
|
2018-01-26 17:12:46 -05:00
|
|
|
const result = reflectorHost.moduleNameToFileName('@angular/core');
|
|
|
|
expect(result).not.toBeNull('could not find @angular/core using path.win32');
|
|
|
|
});
|
2019-08-05 20:13:20 -04:00
|
|
|
});
|