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

Commit 869455e

Browse files
committed
test(generators): add a broken path test
1 parent 861bc36 commit 869455e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/util/typescript-utils.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,38 @@ export class AppModule {}
174174

175175
const knownPath = '/some/fake/path';
176176
const sourceFile = tsUtils.getTypescriptSourceFile(knownPath, knownContent);
177-
const result: any = tsUtils.getNgModuleDecorator('coolFile.ts', sourceFile);
177+
const result = tsUtils.getNgModuleDecorator('coolFile.ts', sourceFile);
178178

179179
expect(result).toEqual(jasmine.any(Object));
180180
});
181+
182+
it('should throw an error', () => {
183+
const messedUpContent = `
184+
import { NgModule } from '@angular/core';
185+
import { BrowserModule } from '@angular/platform-browser';
186+
import { IonicApp, IonicModule } from '../../../../..';
187+
188+
import { AppComponent } from './app.component';
189+
import { RootPageModule } from '../pages/root-page/root-page.module';
190+
191+
({
192+
declarations: [
193+
AppComponent
194+
],
195+
imports: [
196+
BrowserModule,
197+
IonicModule.forRoot(AppComponent),
198+
RootPageModule
199+
],
200+
bootstrap: [IonicApp],
201+
})
202+
export class AppModule {}
203+
204+
`;
205+
const knownPath = '/some/fake/path';
206+
const sourceFile = tsUtils.getTypescriptSourceFile(knownPath, messedUpContent);
207+
208+
expect(() => tsUtils.getNgModuleDecorator('coolFile.ts', sourceFile)).toThrowError('Could not find an "NgModule" decorator in coolFile.ts');
209+
});
181210
});
182211
});

0 commit comments

Comments
 (0)