diff --git a/src/app/features/markdown-render/markdown-render.component.ts b/src/app/features/markdown-render/markdown-render.component.ts index 025e110e..f0e44e9e 100644 --- a/src/app/features/markdown-render/markdown-render.component.ts +++ b/src/app/features/markdown-render/markdown-render.component.ts @@ -13,7 +13,6 @@ import { ViewChild, } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ToolsetOption } from '@ledge-framework/render'; import { Slugger } from 'marked/lib/marked'; import { MarkdownService } from 'ngx-markdown'; import Tocify, { TocItem } from './tocify'; diff --git a/src/app/presentation/case-study/case-study.component.ts b/src/app/presentation/case-study/case-study.component.ts index 5409ac80..83ccadd8 100644 --- a/src/app/presentation/case-study/case-study.component.ts +++ b/src/app/presentation/case-study/case-study.component.ts @@ -11,7 +11,8 @@ import { MatDrawerContent } from '@angular/material/sidenav'; styleUrls: ['./case-study.component.scss'], }) export class CaseStudyComponent implements OnInit { - @ViewChild('drawerContent', {}) drawerContent: MatDrawerContent; + @ViewChild('drawerContent', { static: false }) + drawerContent: MatDrawerContent; cases = [ { displayName: '美团', source: 'meituan' }, @@ -98,8 +99,11 @@ export class CaseStudyComponent implements OnInit { } private resetScrollbar() { - if (this.drawerContent && this.drawerContent.getElementRef()) { - this.drawerContent.getElementRef().nativeElement.scrollTop = 0; + if (!!this.drawerContent) { + // on test drawerContent is different + if (!this.drawerContent.hasOwnProperty('nativeElement')) { + this.drawerContent.getElementRef().nativeElement.scrollTop = 0; + } } } diff --git a/src/app/presentation/solution/solution.component.spec.ts b/src/app/presentation/solution/solution.component.spec.ts index 89eb6bc7..d17fa78c 100644 --- a/src/app/presentation/solution/solution.component.spec.ts +++ b/src/app/presentation/solution/solution.component.spec.ts @@ -11,14 +11,14 @@ describe('SolutionComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [SharedModule, RouterTestingModule], - declarations: [SolutionComponent] - }) - .compileComponents(); + declarations: [SolutionComponent], + }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(SolutionComponent); component = fixture.componentInstance; + component.src = ''; fixture.detectChanges(); }); diff --git a/src/app/presentation/solution/solution.component.ts b/src/app/presentation/solution/solution.component.ts index cbac0397..1ab97d68 100644 --- a/src/app/presentation/solution/solution.component.ts +++ b/src/app/presentation/solution/solution.component.ts @@ -11,7 +11,8 @@ import { MatDrawerContent } from '@angular/material/sidenav'; styleUrls: ['./solution.component.scss'], }) export class SolutionComponent implements OnInit { - @ViewChild('drawerContent', {}) drawerContent: MatDrawerContent; + @ViewChild('drawerContent', { static: false }) + drawerContent: MatDrawerContent; solutions = [{ displayName: 'Coding', source: 'coding' }]; currentSource: string; @@ -78,8 +79,11 @@ export class SolutionComponent implements OnInit { } private resetScrollbar() { - if (this.drawerContent && this.drawerContent.getElementRef()) { - this.drawerContent.getElementRef().nativeElement.scrollTop = 0; + if (!!this.drawerContent) { + // on test drawerContent is different + if (!this.drawerContent.hasOwnProperty('nativeElement')) { + this.drawerContent.getElementRef().nativeElement.scrollTop = 0; + } } }