Skip to content

Commit

Permalink
Updated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Dec 1, 2023
1 parent bb3cb9c commit dad4b11
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/static-page/static-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,42 @@ 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>TEST MESSAGE</div>')
fetchHtmlContent: of('<div id="idShouldNotBeRemoved">TEST MESSAGE</div>')
});
localeService = jasmine.createSpyObj('LocaleService', {
getCurrentLanguageCode: jasmine.createSpy('getCurrentLanguageCode'),
});

appConfig = Object.assign(environment, {
ui: {
namespace: 'testNamespace'
}
});

TestBed.configureTestingModule({
declarations: [ StaticPageComponent ],
declarations: [ StaticPageComponent, ClarinSafeHtmlPipe ],
imports: [
TranslateModule.forRoot()
],
providers: [
{ provide: HtmlContentService, useValue: htmlContentService },
{ provide: Router, useValue: new RouterMock() },
{ provide: LocaleService, useValue: localeService }
{ provide: LocaleService, useValue: localeService },
{ provide: APP_CONFIG, useValue: appConfig }
]
});

Expand All @@ -51,6 +62,6 @@ describe('StaticPageComponent', () => {
// Load `TEST MESSAGE`
it('should load html file content', async () => {
await component.ngOnInit();
expect(component.htmlContent.value).toBe('<div>TEST MESSAGE</div>');
expect(component.htmlContent.value).toBe('<div id="idShouldNotBeRemoved">TEST MESSAGE</div>');
});
});

0 comments on commit dad4b11

Please sign in to comment.