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

Commit 861bc36

Browse files
committed
test(generators): Add first test for getNgModuleDecorator
1 parent 30c82cd commit 861bc36

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

src/util/typescript-utils.spec.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,47 @@ export class TacoBellModule {}
136136
});
137137

138138
it('should return the same file content as the import is already in the file', () => {
139-
const filePath = '/path/to/my/file';
140-
const fileContent = 'import { A } from "modulePath"';
141-
const namedImport = 'A';
142-
const fromModule = `modulePath`;
139+
const filePath = '/path/to/my/file';
140+
const fileContent = 'import { A } from "modulePath"';
141+
const namedImport = 'A';
142+
const fromModule = `modulePath`;
143143

144-
const result = tsUtils.insertNamedImportIfNeeded(filePath, fileContent, namedImport, fromModule);
144+
const result = tsUtils.insertNamedImportIfNeeded(filePath, fileContent, namedImport, fromModule);
145145

146-
expect(result).toEqual(fileContent);
146+
expect(result).toEqual(fileContent);
147+
});
147148
});
149+
150+
describe('getNgModuleDecorator', () => {
151+
it('should return an object', () => {
152+
const knownContent = `
153+
import { NgModule } from '@angular/core';
154+
import { BrowserModule } from '@angular/platform-browser';
155+
import { IonicApp, IonicModule } from '../../../../..';
156+
157+
import { AppComponent } from './app.component';
158+
import { RootPageModule } from '../pages/root-page/root-page.module';
159+
160+
@NgModule({
161+
declarations: [
162+
AppComponent
163+
],
164+
imports: [
165+
BrowserModule,
166+
IonicModule.forRoot(AppComponent),
167+
RootPageModule
168+
],
169+
bootstrap: [IonicApp],
170+
})
171+
export class AppModule {}
172+
173+
`;
174+
175+
const knownPath = '/some/fake/path';
176+
const sourceFile = tsUtils.getTypescriptSourceFile(knownPath, knownContent);
177+
const result: any = tsUtils.getNgModuleDecorator('coolFile.ts', sourceFile);
178+
179+
expect(result).toEqual(jasmine.any(Object));
180+
});
148181
});
149182
});

0 commit comments

Comments
 (0)