Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
make translation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jan 8, 2017
1 parent cddd880 commit 6b65039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/service/alert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ export class AlertService {
private alerts: any[];
private timeout: number;
private i18nEnabled: boolean;
private translateService: TranslateService;

constructor(private sanitizer: Sanitizer, private translateService: TranslateService, private toast: boolean) {
constructor(private sanitizer: Sanitizer, private toast?: boolean, translateService?: TranslateService) {
this.i18nEnabled = ConfigHelper.getConfig().i18nEnabled;
this.alertId = 0; // unique id for each alert. Starts from 0.
this.alerts = [];
this.timeout = 5000; // default timeout
if (this.i18nEnabled) {
this.translateService = translateService;
}
}

clear() {
Expand Down
9 changes: 1 addition & 8 deletions tests/service/alert.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@

import { TestBed, inject } from '@angular/core/testing';
import { Sanitizer } from '@angular/core';
import { TranslateService } from 'ng2-translate';

import { AlertService } from '../../src/service/alert.service';
import { ConfigHelper } from '../../src/helper';

class MockTranslateService extends TranslateService {
instant(msg, params) {
return msg;
}
}

function mockAlertService(sanitizer: Sanitizer) {
return new AlertService(sanitizer, new MockTranslateService(null, null, null), false);
return new AlertService(sanitizer, false);
}

ConfigHelper.setModuleConfigOptions({
Expand Down

0 comments on commit 6b65039

Please sign in to comment.