Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Oct 13, 2023
1 parent 42aaffb commit a83a2a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ClarinAllLicensesPageComponent } from './clarin-all-licenses-page.component';
import {createdLicenseRD$, mockLicenseRD$} from '../../shared/testing/clarin-license-mock';
import {of as observableOf} from 'rxjs';
import {ClarinLicenseDataService} from '../../core/data/clarin/clarin-license-data.service';
import {TranslateModule} from '@ngx-translate/core';

describe('ClarinAllLicensesPageComponent', () => {
let component: ClarinAllLicensesPageComponent;
let fixture: ComponentFixture<ClarinAllLicensesPageComponent>;
let clarinLicenseDataService: ClarinLicenseDataService;

beforeEach(async () => {
clarinLicenseDataService = jasmine.createSpyObj('clarinLicenseService', {
findAll: mockLicenseRD$,
create: createdLicenseRD$,
put: createdLicenseRD$,
searchBy: mockLicenseRD$,
getLinkPath: observableOf('')
});

await TestBed.configureTestingModule({
declarations: [ ClarinAllLicensesPageComponent ]
declarations: [ ClarinAllLicensesPageComponent ],
imports: [
TranslateModule.forRoot(),
],
providers: [
{ provide: ClarinLicenseDataService, useValue: clarinLicenseDataService },
]
})
.compileComponents();
});
Expand Down
31 changes: 26 additions & 5 deletions src/app/static-page/static-page.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
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 {of} from 'rxjs';

Check failure on line 8 in src/app/static-page/static-page.component.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'of' is defined but never used

Check failure on line 8 in src/app/static-page/static-page.component.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'of' is defined but never used

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

let htmlContentService: HtmlContentService;
let localeService: any;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ StaticPageComponent ]
})
.compileComponents();
htmlContentService = jasmine.createSpyObj('htmlContentService', {
fetchHtmlContent: '<div>TEST MESSAGE</div>'
});
localeService = jasmine.createSpyObj('LocaleService', {
getCurrentLanguageCode: jasmine.createSpy('getCurrentLanguageCode'),
});

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

localeService = TestBed.inject(LocaleService);
localeService.getCurrentLanguageCode.and.returnValue('en');
});

beforeEach(() => {
fixture = TestBed.createComponent(StaticPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
Expand Down

0 comments on commit a83a2a5

Please sign in to comment.