Skip to content

Commit

Permalink
feat: init translate for case study
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2020
1 parent da5a639 commit aca4714
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/presentation/case-study/case-study.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mat-drawer-container class="case-study">
<mat-drawer mode="side" opened class="left-drawer">
<h2>案例(出处见来源)</h2>
<h2>{{ 'case-study' | translate }}</h2>
<ul>
<li *ngFor="let casestudy of cases"
(click)="getCase(casestudy.source)"
Expand Down
21 changes: 17 additions & 4 deletions src/app/presentation/case-study/case-study.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CaseStudyComponent } from './case-study.component';
import { SharedModule } from '../../shared/shared.module';
import { RouterTestingModule } from '@angular/router/testing';
import {
TranslateFakeLoader,
TranslateLoader,
TranslateModule,
} from '@ngx-translate/core';

describe('CaseStudyComponent', () => {
let component: CaseStudyComponent;
let fixture: ComponentFixture<CaseStudyComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SharedModule, RouterTestingModule],
declarations: [ CaseStudyComponent ]
})
.compileComponents();
imports: [
SharedModule,
RouterTestingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateFakeLoader,
},
}),
],
declarations: [CaseStudyComponent],
}).compileComponents();
}));

beforeEach(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/app/presentation/case-study/case-study.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MatDrawerContent } from '@angular/material/sidenav';
import { Case, cases } from './cases';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'app-case-study',
Expand All @@ -21,7 +22,8 @@ export class CaseStudyComponent implements OnInit {
constructor(
private title: Title,
private activatedRoute: ActivatedRoute,
private http: HttpClient
private http: HttpClient,
private translate: TranslateService
) {}

ngOnInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/app/presentation/case-study/case-study.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CaseStudyRoutingModule } from './case-study-routing.module';
import { CaseStudyComponent } from './case-study.component';
import { CustomMaterialModule } from 'src/app/shared/custom-material.module';
import { SharedModule } from 'src/app/shared/shared.module';
import { TranslateModule } from '@ngx-translate/core';

@NgModule({
declarations: [CaseStudyComponent],
Expand All @@ -13,6 +14,9 @@ import { SharedModule } from 'src/app/shared/shared.module';
CaseStudyRoutingModule,
CustomMaterialModule,
SharedModule,
TranslateModule.forChild({
isolate: false,
}),
],
})
export class CaseStudyModule {}

0 comments on commit aca4714

Please sign in to comment.