Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit f1fca74

Browse files
authored
refactor: change deprecated api async to waitForAsync (#412)
* refactor: change deprecated api async to waitForAsync * test: fix pages of undefined for css codegen
1 parent 8485cb9 commit f1fca74

File tree

23 files changed

+361
-303
lines changed

23 files changed

+361
-303
lines changed

apps/xlayers-e2e/src/integration/app.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { NO_ERRORS_SCHEMA } from '@angular/core';
2-
import { async, TestBed } from '@angular/core/testing';
2+
import { TestBed, waitForAsync } from '@angular/core/testing';
3+
import { loadSketch, SKETCH_PATH, VERSION_LIST } from '@xlayers/test-helpers';
34
import { WebCodeGenService } from '@xlayers/web-codegen';
45
import { readdirSync } from 'fs';
5-
import { loadSketch, SKETCH_PATH, VERSION_LIST } from '@xlayers/test-helpers';
66

77
describe('sketch parser', () => {
88
let webCodeGen: WebCodeGenService;
99

10-
beforeEach(async(() => {
11-
TestBed.configureTestingModule({
12-
schemas: [NO_ERRORS_SCHEMA],
13-
providers: [WebCodeGenService],
14-
declarations: [],
15-
}).compileComponents();
16-
webCodeGen = TestBed.inject(WebCodeGenService);
17-
}));
10+
beforeEach(
11+
waitForAsync(() => {
12+
TestBed.configureTestingModule({
13+
schemas: [NO_ERRORS_SCHEMA],
14+
providers: [WebCodeGenService],
15+
declarations: [],
16+
}).compileComponents();
17+
webCodeGen = TestBed.inject(WebCodeGenService);
18+
})
19+
);
1820

1921
VERSION_LIST.forEach((version) => {
2022
const fileNames = readdirSync(`${SKETCH_PATH}/${version}`);

apps/xlayers/src/app/editor/code/code.component.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { CodeComponent } from './code.component';
31
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
3+
import { CodeComponent } from './code.component';
44

55
describe('CodeComponent', () => {
66
let component: CodeComponent;
77
let fixture: ComponentFixture<CodeComponent>;
88

9-
beforeEach(async(() => {
10-
TestBed.configureTestingModule({
11-
declarations: [CodeComponent],
12-
schemas: [NO_ERRORS_SCHEMA],
13-
}).compileComponents();
14-
}));
9+
beforeEach(
10+
waitForAsync(() => {
11+
TestBed.configureTestingModule({
12+
declarations: [CodeComponent],
13+
schemas: [NO_ERRORS_SCHEMA],
14+
}).compileComponents();
15+
})
16+
);
1517

1618
beforeEach(() => {
1719
fixture = TestBed.createComponent(CodeComponent);

apps/xlayers/src/app/editor/code/editor-container/editor-container.component.spec.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { NO_ERRORS_SCHEMA } from '@angular/core';
2-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33
import { MatMenuModule } from '@angular/material/menu';
44
import { MatSnackBarModule } from '@angular/material/snack-bar';
55
import { NgxsModule, Store } from '@ngxs/store';
6+
import { CodeGenSettings } from '../../../core/state/page.state';
7+
import { XStore } from '../../../core/state/state.mock';
68
import { CodeGenKind, CodeGenService } from './codegen/codegen.service';
79
import { EditorContainerComponent } from './editor-container.component';
8-
import { XStore } from '../../../core/state/state.mock';
9-
import { CodeGenSettings } from '../../../core/state/page.state';
1010

1111
const codeGenService = {
1212
generate() {
@@ -23,21 +23,27 @@ describe('EditorContainerComponent', () => {
2323
let fixture: ComponentFixture<EditorContainerComponent>;
2424
let store: Store;
2525

26-
beforeEach(async(() => {
27-
TestBed.configureTestingModule({
28-
schemas: [NO_ERRORS_SCHEMA],
29-
imports: [NgxsModule.forRoot([XStore]), MatMenuModule, MatSnackBarModule],
30-
providers: [
31-
{
32-
provide: CodeGenService,
33-
useValue: codeGenService,
34-
},
35-
],
36-
declarations: [EditorContainerComponent],
37-
}).compileComponents();
26+
beforeEach(
27+
waitForAsync(() => {
28+
TestBed.configureTestingModule({
29+
schemas: [NO_ERRORS_SCHEMA],
30+
imports: [
31+
NgxsModule.forRoot([XStore]),
32+
MatMenuModule,
33+
MatSnackBarModule,
34+
],
35+
providers: [
36+
{
37+
provide: CodeGenService,
38+
useValue: codeGenService,
39+
},
40+
],
41+
declarations: [EditorContainerComponent],
42+
}).compileComponents();
3843

39-
store = TestBed.inject(Store);
40-
}));
44+
store = TestBed.inject(Store);
45+
})
46+
);
4147

4248
beforeEach(() => {
4349
fixture = TestBed.createComponent(EditorContainerComponent);

apps/xlayers/src/app/editor/preview/layer-settings/settings-container/settings-container.component.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { SettingsContainerComponent } from './settings-container.component';
41
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
53
import { NgxsModule } from '@ngxs/store';
64
import { XStore } from '../../../../core/state/state.mock';
75

6+
import { SettingsContainerComponent } from './settings-container.component';
7+
88
describe('SettingsContainerComponent', () => {
99
let component: SettingsContainerComponent;
1010
let fixture: ComponentFixture<SettingsContainerComponent>;
1111

12-
beforeEach(async(() => {
13-
TestBed.configureTestingModule({
14-
schemas: [NO_ERRORS_SCHEMA],
15-
imports: [NgxsModule.forRoot([XStore])],
16-
declarations: [SettingsContainerComponent],
17-
}).compileComponents();
18-
}));
12+
beforeEach(
13+
waitForAsync(() => {
14+
TestBed.configureTestingModule({
15+
schemas: [NO_ERRORS_SCHEMA],
16+
imports: [NgxsModule.forRoot([XStore])],
17+
declarations: [SettingsContainerComponent],
18+
}).compileComponents();
19+
})
20+
);
1921

2022
beforeEach(() => {
2123
fixture = TestBed.createComponent(SettingsContainerComponent);

apps/xlayers/src/app/editor/preview/layer-settings/settings-layer-colors/settings-layer-colors.component.spec.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
21
import { NO_ERRORS_SCHEMA } from '@angular/core';
3-
import { NgxsModule } from '@ngxs/store';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
43
import { MatMenuModule } from '@angular/material/menu';
5-
import { SettingsLayerColorsComponent } from './settings-layer-colors.component';
64
import { TranslateModule } from '@ngx-translate/core';
5+
import { NgxsModule } from '@ngxs/store';
76
import { XStore } from '../../../../core/state/state.mock';
7+
import { SettingsLayerColorsComponent } from './settings-layer-colors.component';
88

99
describe('SettingsLayerColorsComponent', () => {
1010
let component: SettingsLayerColorsComponent;
1111
let fixture: ComponentFixture<SettingsLayerColorsComponent>;
1212

13-
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
schemas: [NO_ERRORS_SCHEMA],
16-
imports: [
17-
MatMenuModule,
18-
NgxsModule.forRoot([XStore]),
19-
TranslateModule.forRoot(),
20-
],
21-
declarations: [SettingsLayerColorsComponent],
22-
}).compileComponents();
23-
}));
13+
beforeEach(
14+
waitForAsync(() => {
15+
TestBed.configureTestingModule({
16+
schemas: [NO_ERRORS_SCHEMA],
17+
imports: [
18+
MatMenuModule,
19+
NgxsModule.forRoot([XStore]),
20+
TranslateModule.forRoot(),
21+
],
22+
declarations: [SettingsLayerColorsComponent],
23+
}).compileComponents();
24+
})
25+
);
2426

2527
beforeEach(() => {
2628
fixture = TestBed.createComponent(SettingsLayerColorsComponent);

apps/xlayers/src/app/editor/preview/layer-settings/settings-layer-position/settings-layer-position.component.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { SettingsLayerPositionComponent } from './settings-layer-position.component';
41
import { NO_ERRORS_SCHEMA } from '@angular/core';
5-
import { NgxsModule } from '@ngxs/store';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
63
import { TranslateModule } from '@ngx-translate/core';
4+
import { NgxsModule } from '@ngxs/store';
75
import { XStore } from '../../../../core/state/state.mock';
86

7+
import { SettingsLayerPositionComponent } from './settings-layer-position.component';
8+
99
describe('SettingsLayerPositionComponent', () => {
1010
let component: SettingsLayerPositionComponent;
1111
let fixture: ComponentFixture<SettingsLayerPositionComponent>;
1212

13-
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
schemas: [NO_ERRORS_SCHEMA],
16-
imports: [NgxsModule.forRoot([XStore]), TranslateModule.forRoot()],
17-
declarations: [SettingsLayerPositionComponent],
18-
}).compileComponents();
19-
}));
13+
beforeEach(
14+
waitForAsync(() => {
15+
TestBed.configureTestingModule({
16+
schemas: [NO_ERRORS_SCHEMA],
17+
imports: [NgxsModule.forRoot([XStore]), TranslateModule.forRoot()],
18+
declarations: [SettingsLayerPositionComponent],
19+
}).compileComponents();
20+
})
21+
);
2022

2123
beforeEach(() => {
2224
fixture = TestBed.createComponent(SettingsLayerPositionComponent);

apps/xlayers/src/app/editor/preview/layer-settings/settings-layer-properties/settings-layer-properties.component.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { SettingsLayerPropertiesComponent } from './settings-layer-properties.component';
41
import { NO_ERRORS_SCHEMA } from '@angular/core';
5-
import { NgxsModule } from '@ngxs/store';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
63
import { TranslateModule } from '@ngx-translate/core';
4+
import { NgxsModule } from '@ngxs/store';
75
import { XStore } from '../../../../core/state/state.mock';
86

7+
import { SettingsLayerPropertiesComponent } from './settings-layer-properties.component';
8+
99
describe('SettingsLayerPropertiesComponent', () => {
1010
let component: SettingsLayerPropertiesComponent;
1111
let fixture: ComponentFixture<SettingsLayerPropertiesComponent>;
1212

13-
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
schemas: [NO_ERRORS_SCHEMA],
16-
imports: [NgxsModule.forRoot([XStore]), TranslateModule.forRoot()],
17-
declarations: [SettingsLayerPropertiesComponent],
18-
}).compileComponents();
19-
}));
13+
beforeEach(
14+
waitForAsync(() => {
15+
TestBed.configureTestingModule({
16+
schemas: [NO_ERRORS_SCHEMA],
17+
imports: [NgxsModule.forRoot([XStore]), TranslateModule.forRoot()],
18+
declarations: [SettingsLayerPropertiesComponent],
19+
}).compileComponents();
20+
})
21+
);
2022

2123
beforeEach(() => {
2224
fixture = TestBed.createComponent(SettingsLayerPropertiesComponent);

apps/xlayers/src/app/editor/preview/layer-settings/settings-preview/settings-layer-colors.component.spec.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { SettingsPreviewComponent } from './settings-preview.component';
41
import { NO_ERRORS_SCHEMA } from '@angular/core';
5-
import { NgxsModule } from '@ngxs/store';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
63
import { MatMenuModule } from '@angular/material/menu';
74
import { TranslateModule } from '@ngx-translate/core';
5+
import { NgxsModule } from '@ngxs/store';
86
import { XStore } from '../../../../core/state/state.mock';
97

8+
import { SettingsPreviewComponent } from './settings-preview.component';
9+
1010
describe('SettingsPreviewComponent', () => {
1111
let component: SettingsPreviewComponent;
1212
let fixture: ComponentFixture<SettingsPreviewComponent>;
1313

14-
beforeEach(async(() => {
15-
TestBed.configureTestingModule({
16-
schemas: [NO_ERRORS_SCHEMA],
17-
imports: [
18-
MatMenuModule,
19-
NgxsModule.forRoot([XStore]),
20-
TranslateModule.forRoot(),
21-
],
22-
declarations: [SettingsPreviewComponent],
23-
}).compileComponents();
24-
}));
14+
beforeEach(
15+
waitForAsync(() => {
16+
TestBed.configureTestingModule({
17+
schemas: [NO_ERRORS_SCHEMA],
18+
imports: [
19+
MatMenuModule,
20+
NgxsModule.forRoot([XStore]),
21+
TranslateModule.forRoot(),
22+
],
23+
declarations: [SettingsPreviewComponent],
24+
}).compileComponents();
25+
})
26+
);
2527

2628
beforeEach(() => {
2729
fixture = TestBed.createComponent(SettingsPreviewComponent);

apps/xlayers/src/app/editor/preview/layer-tree-layout/layer-tree-layout.component.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { TreeViewComponent } from './layer-tree-layout.component';
41
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
53
import { MatTreeModule } from '@angular/material/tree';
64
import { NgxsModule } from '@ngxs/store';
75
import { XStore } from '../../../core/state/state.mock';
86

7+
import { TreeViewComponent } from './layer-tree-layout.component';
8+
99
describe('TreeViewComponent', () => {
1010
let component: TreeViewComponent;
1111
let fixture: ComponentFixture<TreeViewComponent>;
1212

13-
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
schemas: [NO_ERRORS_SCHEMA],
16-
imports: [MatTreeModule, NgxsModule.forRoot([XStore])],
17-
declarations: [TreeViewComponent],
18-
}).compileComponents();
19-
}));
13+
beforeEach(
14+
waitForAsync(() => {
15+
TestBed.configureTestingModule({
16+
schemas: [NO_ERRORS_SCHEMA],
17+
imports: [MatTreeModule, NgxsModule.forRoot([XStore])],
18+
declarations: [TreeViewComponent],
19+
}).compileComponents();
20+
})
21+
);
2022

2123
beforeEach(() => {
2224
fixture = TestBed.createComponent(TreeViewComponent);

apps/xlayers/src/app/editor/preview/preview.component.spec.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import { NO_ERRORS_SCHEMA } from '@angular/compiler/src/core';
2-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33
import { MatMenuModule } from '@angular/material/menu';
4-
import { NgxsModule } from '@ngxs/store';
5-
import { PreviewComponent } from './preview.component';
64
import { TranslateModule } from '@ngx-translate/core';
5+
import { NgxsModule } from '@ngxs/store';
76
import { XStore } from '../../core/state/state.mock';
7+
import { PreviewComponent } from './preview.component';
88

99
describe('PreviewComponent', () => {
1010
let component: PreviewComponent;
1111
let fixture: ComponentFixture<PreviewComponent>;
1212

13-
beforeEach(async(() => {
14-
TestBed.configureTestingModule({
15-
declarations: [PreviewComponent],
16-
imports: [
17-
MatMenuModule,
18-
NgxsModule.forRoot([XStore]),
19-
TranslateModule.forRoot(),
20-
],
21-
schemas: [NO_ERRORS_SCHEMA],
22-
}).compileComponents();
23-
}));
13+
beforeEach(
14+
waitForAsync(() => {
15+
TestBed.configureTestingModule({
16+
declarations: [PreviewComponent],
17+
imports: [
18+
MatMenuModule,
19+
NgxsModule.forRoot([XStore]),
20+
TranslateModule.forRoot(),
21+
],
22+
schemas: [NO_ERRORS_SCHEMA],
23+
}).compileComponents();
24+
})
25+
);
2426

2527
beforeEach(() => {
2628
fixture = TestBed.createComponent(PreviewComponent);

0 commit comments

Comments
 (0)