forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstatic-page.component.spec.ts
More file actions
69 lines (59 loc) · 2.4 KB
/
Copy pathstatic-page.component.spec.ts
File metadata and controls
69 lines (59 loc) · 2.4 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StaticPageComponent } from './static-page.component';
import { HtmlContentService } from '../shared/html-content.service';
import { Router } from '@angular/router';
import { RouterMock } from '../shared/mocks/router.mock';
import { LocaleService } from '../core/locale/locale.service';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { APP_CONFIG } from '../../config/app-config.interface';
import { environment } from '../../environments/environment';
import { ClarinSafeHtmlPipe } from '../shared/utils/clarin-safehtml.pipe';
describe('StaticPageComponent', () => {
let component: StaticPageComponent;
let fixture: ComponentFixture<StaticPageComponent>;
let htmlContentService: HtmlContentService;
let localeService: any;
let appConfig: any;
beforeEach(async () => {
htmlContentService = jasmine.createSpyObj('htmlContentService', {
fetchHtmlContent: of('<div id="idShouldNotBeRemoved">TEST MESSAGE</div>')
});
localeService = jasmine.createSpyObj('LocaleService', {
getCurrentLanguageCode: jasmine.createSpy('getCurrentLanguageCode'),
});
// Do not mutate the shared `environment` object - replacing `environment.ui` would
// break any later spec that reads e.g. environment.ui.nameSpace
appConfig = Object.assign({}, environment, {
ui: {
namespace: 'testNamespace'
}
});
TestBed.configureTestingModule({
declarations: [ StaticPageComponent, ClarinSafeHtmlPipe ],
imports: [
TranslateModule.forRoot()
],
providers: [
{ provide: HtmlContentService, useValue: htmlContentService },
{ provide: Router, useValue: new RouterMock() },
{ provide: LocaleService, useValue: localeService },
{ provide: APP_CONFIG, useValue: appConfig }
]
});
localeService = TestBed.inject(LocaleService);
localeService.getCurrentLanguageCode.and.returnValue('en');
});
beforeEach(() => {
fixture = TestBed.createComponent(StaticPageComponent);
component = fixture.componentInstance;
});
it('should create', () => {
expect(component).toBeTruthy();
});
// Load `TEST MESSAGE`
it('should load html file content', async () => {
await component.ngOnInit();
expect(component.htmlContent.value).toBe('<div id="idShouldNotBeRemoved">TEST MESSAGE</div>');
});
});