mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(docs-infra): fix broken adev tests (#64761)
Fixes some adev tests that are broken on main. PR Close #64761
This commit is contained in:
@@ -14,6 +14,7 @@ import {NodeRuntimeSandbox} from '../../editor/node-runtime-sandbox.service';
|
||||
|
||||
import TutorialPlayground from './playground.component';
|
||||
import {provideRouter} from '@angular/router';
|
||||
import {mockAsyncProvider} from '../../core/services/inject-async';
|
||||
|
||||
describe('TutorialPlayground', () => {
|
||||
let component: TutorialPlayground;
|
||||
@@ -26,6 +27,14 @@ describe('TutorialPlayground', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
class FakeEmbeddedTutorialManager {
|
||||
fetchAndSetTutorialFiles() {}
|
||||
}
|
||||
|
||||
class FakeNodeRuntimeSandbox {
|
||||
init() {}
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TutorialPlayground],
|
||||
providers: [
|
||||
@@ -34,18 +43,8 @@ describe('TutorialPlayground', () => {
|
||||
provide: WINDOW,
|
||||
useValue: fakeWindow,
|
||||
},
|
||||
{
|
||||
provide: EmbeddedTutorialManager,
|
||||
useValue: {
|
||||
fetchAndSetTutorialFiles: () => {},
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: NodeRuntimeSandbox,
|
||||
useVaue: {
|
||||
init: () => {},
|
||||
},
|
||||
},
|
||||
mockAsyncProvider(NodeRuntimeSandbox, FakeNodeRuntimeSandbox),
|
||||
mockAsyncProvider(EmbeddedTutorialManager, FakeEmbeddedTutorialManager),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export default class PlaygroundComponent {
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.changeDetectorRef.markForCheck();
|
||||
this.nodeRuntimeSandbox!.init();
|
||||
this.nodeRuntimeSandbox?.init();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export default class PlaygroundComponent {
|
||||
});
|
||||
this.selectedTemplate = template;
|
||||
await this.loadTemplate(template.path);
|
||||
await this.nodeRuntimeSandbox!.reset();
|
||||
await this.nodeRuntimeSandbox?.reset();
|
||||
}
|
||||
|
||||
private async loadTemplate(tutorialPath: string) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import ApiItemLabel from './api-item-label.component';
|
||||
import {ApiItemType} from '../interfaces/api-item-type';
|
||||
|
||||
describe('ApiItemLabel', () => {
|
||||
let component: ApiItemLabel;
|
||||
let fixture: ComponentFixture<ApiItemLabel>;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -20,12 +19,10 @@ describe('ApiItemLabel', () => {
|
||||
imports: [ApiItemLabel],
|
||||
});
|
||||
fixture = TestBed.createComponent(ApiItemLabel);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should by default display short label for Class', () => {
|
||||
fixture.componentRef.setInput('type', ApiItemType.CLASS);
|
||||
fixture.componentRef.setInput('mode', 'short');
|
||||
fixture.detectChanges();
|
||||
|
||||
const label = fixture.nativeElement.innerText;
|
||||
|
||||
Reference in New Issue
Block a user