-
Notifications
You must be signed in to change notification settings - Fork 112
/
component-mock-external.component.spec.ts
37 lines (31 loc) · 1.15 KB
/
component-mock-external.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* tslint:disable:no-unused-variable */
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { WithExternalServiceComponent } from './component-mock-external.component';
import { LanguageService, LanguageEnum } from './language.service';
describe('ContentProjectionComponent', () => {
let component: WithExternalServiceComponent;
let langService: LanguageService;
beforeEach(() => {
langService = new LanguageService();
component = new WithExternalServiceComponent(langService);
});
afterEach(() => {
langService = null;
component = null;
});
it('should greet in italian when the lang is IT', () => {
langService.setCurrentLanguage(LanguageEnum.IT);
expect(component.getGreeting()).toBe('Ciao');
});
it('should greet in german when the lang is DE', () => {
spyOnProperty(langService, 'currentLang', 'get').and.returnValue(
LanguageEnum.DE
);
expect(component.getGreeting()).toBe('Hallo');
});
it('should greet in english by default', () => {
expect(component.getGreeting()).toBe('Hi');
});
});