Skip to content

Commit 73b692e

Browse files
fix schematic tests
1 parent f099a81 commit 73b692e

File tree

4 files changed

+15
-55
lines changed

4 files changed

+15
-55
lines changed

packages/devextreme-schematics/src/add-layout/files/src/app/__name__.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, HostBinding } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { RouterModule, RouterOutlet } from '@angular/router';
4-
import {ScreenService, AppInfoService, AuthService } from './shared/services';
4+
import { AuthService, ScreenService, AppInfoService } from './shared/services';
55
import { DxHttpModule } from 'devextreme-angular/http';
66
import { SideNavOuterToolbarComponent, SideNavInnerToolbarComponent } from './layouts';
77
import { FooterComponent } from './shared/components';

packages/devextreme-schematics/src/add-layout/index_spec.ts

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,17 @@ describe('layout', () => {
101101
expect(styles[3]).toBe('src/themes/generated/theme.additional.dark.css');
102102
expect(styles[4]).toBe('src/themes/generated/theme.additional.css');
103103

104-
const moduleContent = tree.readContent('/src/app/app.module.ts');
105-
expect(moduleContent).toContain('import { DxHttpModule }');
106-
expect(moduleContent)
107-
.toContain('import { SideNavOuterToolbarComponent, SideNavInnerToolbarComponent, SingleCardComponent }');
108-
expect(moduleContent)
109-
.toContain(`import { AuthService, ScreenService, AppInfoService } from './shared/services';`);
110-
expect(moduleContent).toContain('import { AppRoutingModule }');
111-
expect(moduleContent)
112-
.toContain('import { FooterComponent, ' +
113-
'ResetPasswordFormComponent, ' +
114-
'CreateAccountFormComponent, ' +
115-
'ChangePasswordFormComponent, ' +
116-
'LoginFormComponent }');
117-
118104
const appContent = tree.readContent('/src/app/app.component.ts');
105+
expect(appContent).toContain('import { DxHttpModule }');
106+
expect(appContent)
107+
.toContain('import { SideNavOuterToolbarComponent, SideNavInnerToolbarComponent }');
108+
expect(appContent)
109+
.toContain(`import { AuthService, ScreenService, AppInfoService } from './shared/services';`);
110+
expect(appContent)
111+
.toContain('import { FooterComponent }');
119112
expect(appContent).toContain('templateUrl: \'./app.component.html\',');
120113
expect(appContent).toContain('styleUrls: [\'./app.component.scss\']');
121114
expect(appContent).toContain('selector: \'app-root\',');
122-
expect(appContent).toContain(`import { AuthService, ScreenService, AppInfoService } from './shared/services';`);
123115

124116
const navigationMenu = tree.readContent(
125117
'/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts');
@@ -244,26 +236,14 @@ describe('layout', () => {
244236
});
245237

246238
it('should add routing to layout', async () => {
247-
let newAppTree = await schematicRunner.runSchematic('workspace', workspaceOptions);
248-
249-
appOptions.routing = false;
250-
newAppTree = await schematicRunner.runSchematic(
251-
'application', appOptions, newAppTree);
252-
253239
const runner = new SchematicTestRunner('schematics', collectionPath);
254240
const tree = await runner.runSchematic('add-layout', options, appTree);
255241

256242
expect(tree.files).toContain('/src/app/app.routes.ts');
257-
const moduleContent = tree.readContent('/src/app/app.routes.ts');
258-
expect(moduleContent)
259-
.toMatch(/imports:\s\[RouterModule\.forRoot\(routes, { useHash: true }\)\],/);
260-
261-
expect(moduleContent)
262-
.toContain(`{
263-
path: 'login-form',
264-
component: LoginFormComponent,
265-
canActivate: [ AuthGuardService ]
266-
}`);
243+
const routesContent = tree.readContent('/src/app/app.routes.ts');
244+
245+
expect(routesContent)
246+
.toContain(`{\r\n path: 'login-form',\r\n component: LoginFormComponent,\r\n canActivate: [ AuthGuardService ]\r\n },`);
267247
});
268248

269249
it('should use selected layout', async () => {

packages/devextreme-schematics/src/add-sample-views/index_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ describe('sample views', () => {
4646
expect(moduleContent).toMatch(/path: 'home'/);
4747

4848
expect(moduleContent).toMatch(/import { HomeComponent } from /);
49-
expect(moduleContent).toMatch(/declarations:\s\[\n*\s*HomeComponent/);
5049

5150
const navigationContent = tree.readContent('/src/app/app-navigation.ts');
5251
expect(navigationContent).toMatch(/text: 'Home'/);

packages/devextreme-schematics/src/add-view/index_spec.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('view', () => {
6060
expect(contentTS).toContain(`selector: 'app-${componentName}'`);
6161
expect(contentTS).toContain(`templateUrl: './${componentName}.component.html'`);
6262
expect(contentTS).toContain(`styleUrl: './${componentName}.component.css'`);
63-
expect(contentTS).toContain('standalone: false');
63+
expect(contentTS).toContain('standalone: true');
6464
expect(contentTS).toContain(`export class ${strings.classify(basename(normalize(componentName)))}Component`);
6565
});
6666

@@ -73,27 +73,8 @@ describe('view', () => {
7373
tree = await runner.runSchematic('add-view', { ...options, name: 'test2' }, tree);
7474
const moduleContent = tree.readContent('/src/app/app.routes.ts');
7575

76-
expect(moduleContent).toContain(`const routes: Routes = [
77-
{
78-
path: 'pages/test2',
79-
component: Test2Component,
80-
canActivate: [ AuthGuardService ]
81-
},
82-
{
83-
path: 'pages/test',
84-
component: TestComponent,
85-
canActivate: [ AuthGuardService ]
86-
},
87-
{
88-
path: 'login-form',
89-
component: LoginFormComponent,
90-
canActivate: [ AuthGuardService ]
91-
},
92-
{
93-
path: '**',
94-
redirectTo: 'pages/test'
95-
}
96-
];`);
76+
expect(moduleContent).toContain(`path: 'pages/test2',\n component: Test2Component,\n canActivate: [ AuthGuardService ]`);
77+
expect(moduleContent).toContain(`path: 'pages/test',\n component: TestComponent,\n canActivate: [ AuthGuardService ]`);
9778
});
9879

9980
it('should add view to other routing module', async () => {

0 commit comments

Comments
 (0)