test(language-service): remove MockData from MockTypescriptHost (#32752)

Remove MockData from the constructor parameters of MockTypescriptHost
since the entire Tour of Heroes (TOH) project is now loaded from disk.

Added a new method `reset()` to MockTypescriptHost that is necessary to
reset the state of the project before each spec if run to make sure
previous overrides are cleared.

PR Close #32752
This commit is contained in:
Keen Yee Liau
2019-09-17 14:33:41 -07:00
committed by Andrew Kushnir
parent 0450f39625
commit f3859ff2b9
12 changed files with 64 additions and 343 deletions

View File

@ -8,7 +8,6 @@
import * as ts from 'typescript';
import {getClassDeclFromDecoratorProp} from '../src/template';
import {toh} from './test_data';
import {MockTypescriptHost} from './test_utils';
describe('getClassDeclFromTemplateNode', () => {
@ -35,7 +34,7 @@ describe('getClassDeclFromTemplateNode', () => {
it('should return class declaration for AppComponent', () => {
const host = new MockTypescriptHost(['/app/app.component.ts'], toh);
const host = new MockTypescriptHost(['/app/app.component.ts']);
const tsLS = ts.createLanguageService(host);
const sourceFile = tsLS.getProgram() !.getSourceFile('/app/app.component.ts');
expect(sourceFile).toBeTruthy();