Skip to content

Commit 8b649a1

Browse files
Mattia VianelliMattia Vianelli
authored andcommitted
DSC-2458 Test fix
1 parent 56fdc62 commit 8b649a1

2 files changed

Lines changed: 7 additions & 30 deletions

File tree

src/app/info/cms-info/cms-info.component.spec.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,23 @@ import {
33
TestBed,
44
} from '@angular/core/testing';
55
import { ActivatedRoute } from '@angular/router';
6-
import { Store } from '@ngrx/store';
76
import { TranslateModule } from '@ngx-translate/core';
87
import { MockComponent } from 'ng-mocks';
98
import {
109
Observable,
1110
of,
1211
} from 'rxjs';
13-
import { AuthService } from 'src/app/core/auth/auth.service';
14-
import { AuthTokenInfo } from 'src/app/core/auth/models/auth-token-info.model';
15-
import { ObjectCacheService } from 'src/app/core/cache/object-cache.service';
1612
import { SiteDataService } from 'src/app/core/data/site-data.service';
1713
import { LocaleService } from 'src/app/core/locale/locale.service';
18-
import { CookieService } from 'src/app/core/services/cookie.service';
19-
import {
20-
NativeWindowRef,
21-
NativeWindowService,
22-
} from 'src/app/core/services/window.service';
2314
import { Site } from 'src/app/core/shared/site.model';
24-
import { CookieServiceMock } from 'src/app/shared/mocks/cookie.service.mock';
2515

2616
import { MarkdownViewerComponent } from '../../shared/markdown-viewer/markdown-viewer.component';
2717
import { CmsInfoComponent } from './cms-info.component';
2818

2919
describe('CmsInfoComponent', () => {
3020
let component: CmsInfoComponent;
3121
let fixture: ComponentFixture<CmsInfoComponent>;
32-
let authService: AuthService;
33-
let token: AuthTokenInfo;
34-
let store;
35-
let redirectUrl: string;
22+
let localeServiceSpy: jasmine.SpyObj<LocaleService>;
3623
let activatedRouteStub: any;
3724
let siteServiceStub: any;
3825

@@ -50,13 +37,8 @@ describe('CmsInfoComponent', () => {
5037
});
5138

5239
beforeEach(async () => {
53-
redirectUrl = 'redirect/url';
54-
token = new AuthTokenInfo('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9');
55-
authService = jasmine.createSpyObj('authService', {
56-
isAuthenticated: of(true),
57-
getToken: token,
58-
});
59-
store = jasmine.createSpyObj('store', ['dispatch']);
40+
localeServiceSpy = jasmine.createSpyObj('LocaleService', ['getCurrentLanguageCode']);
41+
localeServiceSpy.getCurrentLanguageCode.and.returnValue(of('en'));
6042
activatedRouteStub = {
6143
data: of({ schema: 'cris', qualifier: 'testQualifier' }),
6244
queryParamMap: of({}),
@@ -73,13 +55,8 @@ describe('CmsInfoComponent', () => {
7355
MockComponent(MarkdownViewerComponent),
7456
],
7557
providers: [
76-
LocaleService,
77-
ObjectCacheService,
7858
{ provide: SiteDataService, useValue: siteServiceStub },
79-
{ provide: Store, useValue: store },
80-
{ provide: AuthService, useValue: authService },
81-
{ provide: CookieService, useValue: new CookieServiceMock },
82-
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
59+
{ provide: LocaleService, useValue: localeServiceSpy },
8360
{ provide: ActivatedRoute, useValue: activatedRouteStub },
8461
],
8562
})

src/app/info/privacy/privacy-content/privacy-content.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('PrivacyContentComponent', () => {
2424
localeServiceSpy = jasmine.createSpyObj('LocaleService', ['getCurrentLanguageCode']);
2525

2626
siteServiceSpy.find.and.returnValue(of({ metadataAsList: [] } as any));
27-
localeServiceSpy.getCurrentLanguageCode.and.returnValue('en');
27+
localeServiceSpy.getCurrentLanguageCode.and.returnValue(of('en'));
2828

2929
TestBed.configureTestingModule({
3030
imports: [TranslateModule.forRoot(), PrivacyContentComponent],
@@ -55,7 +55,7 @@ describe('PrivacyContentComponent', () => {
5555
};
5656

5757
siteServiceSpy.find.and.returnValue(of(mockSite as any));
58-
localeServiceSpy.getCurrentLanguageCode.and.returnValue('it');
58+
localeServiceSpy.getCurrentLanguageCode.and.returnValue(of('it'));
5959

6060
component.ngOnInit();
6161

@@ -74,7 +74,7 @@ describe('PrivacyContentComponent', () => {
7474
};
7575

7676
siteServiceSpy.find.and.returnValue(of(mockSite as any));
77-
localeServiceSpy.getCurrentLanguageCode.and.returnValue('it');
77+
localeServiceSpy.getCurrentLanguageCode.and.returnValue(of('it'));
7878

7979
component.ngOnInit();
8080

0 commit comments

Comments
 (0)