@ -285,6 +285,22 @@ describe('NgCompilerHost', () => {
|
||||
expect(sf.referencedFiles.length).toBe(1);
|
||||
expect(sf.referencedFiles[0].fileName).toBe('main.ts');
|
||||
});
|
||||
|
||||
it('should generate for tsx files', () => {
|
||||
codeGenerator.findGeneratedFileNames.and.returnValue(['/tmp/src/index.ngfactory.ts']);
|
||||
codeGenerator.generateFile.and.returnValue(aGeneratedFile);
|
||||
const host = createHost({files: {'tmp': {'src': {'index.tsx': ``}}}});
|
||||
|
||||
const genSf = host.getSourceFile('/tmp/src/index.ngfactory.ts', ts.ScriptTarget.Latest);
|
||||
expect(genSf.text).toBe(aGeneratedFileText);
|
||||
|
||||
const sf = host.getSourceFile('/tmp/src/index.tsx', ts.ScriptTarget.Latest);
|
||||
expect(sf.referencedFiles[0].fileName).toBe('/tmp/src/index.ngfactory.ts');
|
||||
|
||||
// the codegen should have been cached
|
||||
expect(codeGenerator.generateFile).toHaveBeenCalledTimes(1);
|
||||
expect(codeGenerator.findGeneratedFileNames).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateSourceFile', () => {
|
||||
|
@ -391,6 +391,22 @@ describe('ng program', () => {
|
||||
testSupport.shouldExist('built/src/main.ngfactory.d.ts');
|
||||
});
|
||||
|
||||
it('should work with tsx files', () => {
|
||||
// create a temporary ts program to get the list of all files from angular...
|
||||
testSupport.writeFiles({
|
||||
'src/main.tsx': createModuleAndCompSource('main'),
|
||||
});
|
||||
const allRootNames = resolveFiles([path.resolve(testSupport.basePath, 'src/main.tsx')]);
|
||||
|
||||
const program = compile(undefined, {jsx: ts.JsxEmit.React}, allRootNames);
|
||||
|
||||
testSupport.shouldExist('built/src/main.js');
|
||||
testSupport.shouldExist('built/src/main.d.ts');
|
||||
testSupport.shouldExist('built/src/main.ngfactory.js');
|
||||
testSupport.shouldExist('built/src/main.ngfactory.d.ts');
|
||||
testSupport.shouldExist('built/src/main.ngsummary.json');
|
||||
});
|
||||
|
||||
it('should emit also empty generated files depending on the options', () => {
|
||||
testSupport.writeFiles({
|
||||
'src/main.ts': `
|
||||
|
Reference in New Issue
Block a user