Skip to content

Commit ac543fd

Browse files
author
Andrea Barbasso
committed
[DSC-2256] fix tests build issues
1 parent 24ef528 commit ac543fd

36 files changed

Lines changed: 136 additions & 155 deletions

File tree

src/app/admin/admin-notifications/admin-notifications-suggestion-targets-page/admin-notifications-suggestion-targets-page.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Component } from '@angular/core';
2+
import {
3+
PublicationClaimComponent
4+
} from '../../../notifications/suggestions/targets/publication-claim/publication-claim.component';
25

3-
import { PublicationClaimComponent } from '../../../notifications/suggestion-targets/publication-claim/publication-claim.component';
46

57
@Component({
68
selector: 'ds-admin-notifications-reciter-page',

src/app/app.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import {
4343
NativeWindowService,
4444
} from './core/services/window.service';
4545
import { ThemedRootComponent } from './root/themed-root.component';
46-
import { KlaroService } from './shared/cookies/klaro.service';
4746
import { DatadogRumService } from './shared/datadog-rum/datadog-rum.service';
4847
import { HostWindowResizeAction } from './shared/host-window.actions';
4948
import { HostWindowService } from './shared/host-window.service';
@@ -62,6 +61,7 @@ import { MenuServiceStub } from './shared/testing/menu-service.stub';
6261
import { ThemeService } from './shared/theme-support/theme.service';
6362
import { SocialComponent } from './social/social.component';
6463
import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider';
64+
import { OrejimeService } from './shared/cookies/orejime.service';
6565

6666
let comp: AppComponent;
6767
let fixture: ComponentFixture<AppComponent>;
@@ -83,7 +83,7 @@ describe('App component', () => {
8383

8484
let breadcrumbsServiceSpy;
8585
let routeServiceMock;
86-
let klaroServiceSpy: jasmine.SpyObj<KlaroService>;
86+
let orejimeServiceSpy: jasmine.SpyObj<OrejimeService>;
8787
let datadogRumServiceSpy: jasmine.SpyObj<DatadogRumService>;
8888
let routerEventsObs: Subject<any>;
8989
let routerMock: Router;
@@ -99,7 +99,7 @@ describe('App component', () => {
9999
events: routerEventsObs,
100100
});
101101

102-
klaroServiceSpy = jasmine.createSpyObj('KlaroService', {
102+
orejimeServiceSpy = jasmine.createSpyObj('OrejimeService', {
103103
getSavedPreferences: jasmine.createSpy('getSavedPreferences'),
104104
watchConsentUpdates: jasmine.createSpy('watchConsentUpdates').and.returnValue(null),
105105
},{
@@ -137,7 +137,7 @@ describe('App component', () => {
137137
{ provide: BreadcrumbsService, useValue: breadcrumbsServiceSpy },
138138
{ provide: RouteService, useValue: routeServiceMock },
139139
{ provide: APP_CONFIG, useValue: environment },
140-
{ provide: KlaroService, useValue: klaroServiceSpy },
140+
{ provide: OrejimeService, useValue: orejimeServiceSpy },
141141
{ provide: DatadogRumService, useValue: datadogRumServiceSpy },
142142
provideMockStore({ initialState }),
143143
AppComponent,

src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ describe('EditBitstreamPageComponent', () => {
800800
{
801801
provide: ActivatedRoute,
802802
useValue: {
803-
data: observableOf({ bitstream: createSuccessfulRemoteDataObject(bitstream) }),
803+
data: of({ bitstream: createSuccessfulRemoteDataObject(bitstream) }),
804804
snapshot: { queryParams: {} },
805805
},
806806
},
@@ -930,7 +930,7 @@ describe('EditBitstreamPageComponent', () => {
930930
{
931931
provide: ActivatedRoute,
932932
useValue: {
933-
data: observableOf({ bitstream: createSuccessfulRemoteDataObject(bitstream) }),
933+
data: of({ bitstream: createSuccessfulRemoteDataObject(bitstream) }),
934934
snapshot: { queryParams: {} },
935935
},
936936
},

src/app/core/auth/auth.effects.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ describe('AuthEffects', () => {
497497
it('should return a REFRESH_STATE_TOKEN_AND_REDIRECT_SUCCESS action in response to a REFRESH_STATE_TOKEN_AND_REDIRECT action', (done) => {
498498

499499
store.overrideSelector(getAuthenticatedUser, { id: EPersonMock.id } as EPerson);
500-
spyOn((authEffects as any).authService, 'retrieveAuthenticatedUserById').and.returnValue(observableOf(EPersonMock));
500+
spyOn((authEffects as any).authService, 'retrieveAuthenticatedUserById').and.returnValue(of(EPersonMock));
501501

502502
actions = hot('--a-', {
503503
a: {

src/app/core/shared/metadata.utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('Metadata', () => {
183183

184184
describe('hasValue method', () => {
185185
const testHasValue = (value, expected) =>
186-
testMethod(Metadata.hasValue, 'boolean', value, null, expected);
186+
testMethod(Metadata.hasValue, 'boolean', value, null, undefined, expected, undefined, undefined);
187187

188188
describe('with undefined value', () => {
189189
testHasValue(undefined, false);

src/app/correlation-id/correlation-id.service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
StoreModule,
55
} from '@ngrx/store';
66
import { MockStore } from '@ngrx/store/testing';
7-
import { of } from 'rxjs';
7+
import { BehaviorSubject, of } from 'rxjs';
88

99
import {
1010
appReducers,
@@ -40,6 +40,9 @@ describe('CorrelationIdService', () => {
4040
getSavedPreferences: () => of({ CORRELATION_ID_OREJIME_KEY: true }),
4141
initialize: jasmine.createSpy('initialize'),
4242
showSettings: jasmine.createSpy('showSettings'),
43+
watchConsentUpdates: () => of(),
44+
consentsUpdates$: new BehaviorSubject({ CORRELATION_ID_OREJIME_KEY: true }),
45+
initialized$: new BehaviorSubject(true),
4346
};
4447

4548
service = new CorrelationIdService(cookieService, uuidService, store, mockOrejimeService, { nativeWindow: undefined });
Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DsDatePipe } from './ds-date.pipe';
2+
import { waitForAsync } from '@angular/core/testing';
23

34
describe('DsDatePipe', () => {
45

@@ -24,28 +25,33 @@ describe('DsDatePipe', () => {
2425
expect(pipe).toBeTruthy();
2526
});
2627

27-
it('Should transform the given date and time', () => {
28-
const value = pipe.transform(`${date}T11:22:33Z`);
29-
expect(value).toEqual(parsedDate);
30-
});
31-
32-
it('Should transform the given date (YYYY-MM-DD)', () => {
33-
const value = pipe.transform(date);
34-
expect(value).toEqual(parsedDate);
35-
});
36-
37-
it('Should transform the given date (YYYY-MM)', () => {
38-
const value = pipe.transform('2020-08');
39-
expect(value).toEqual('August 2020');
40-
});
41-
42-
it('Should transform the given date (YYYY)', () => {
43-
const value = pipe.transform('2020');
44-
expect(value).toEqual('2020');
45-
});
46-
47-
it('Should not transform invalid dates', () => {
48-
const value = pipe.transform('ABCDE');
49-
expect(value).toEqual('ABCDE');
50-
});
28+
it('Should transform the given date and time', waitForAsync(() => {
29+
pipe.transform(`${date}T11:22:33Z`).subscribe(value => {
30+
expect(value).toEqual(parsedDate);
31+
});
32+
}));
33+
34+
it('Should transform the given date (YYYY-MM-DD)', waitForAsync(() => {
35+
pipe.transform(date).subscribe(value => {
36+
expect(value).toEqual(parsedDate);
37+
});
38+
}));
39+
40+
it('Should transform the given date (YYYY-MM)', waitForAsync(() => {
41+
pipe.transform('2020-08').subscribe(value => {
42+
expect(value).toEqual('August 2020');
43+
});
44+
}));
45+
46+
it('Should transform the given date (YYYY)', waitForAsync(() => {
47+
pipe.transform('2020').subscribe(value => {
48+
expect(value).toEqual('2020');
49+
});
50+
}));
51+
52+
it('Should not transform invalid dates', waitForAsync(() => {
53+
pipe.transform('ABCDE').subscribe(value => {
54+
expect(value).toEqual('ABCDE');
55+
});
56+
}));
5157
});

src/app/cris-layout/services/resolver-strategy.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('ResolverStrategyService', () => {
1313

1414
beforeEach(() => {
1515
TestBed.configureTestingModule({});
16-
service = TestBed.get(ResolverStrategyService);
16+
service = new ResolverStrategyService();
1717
});
1818

1919
it('should be created', () => {

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value-field/dso-edit-metadata-authority-field/dso-edit-metadata-authority-field.component.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ describe('DsoEditMetadataAuthorityFieldComponent', () => {
6666
href: 'entries',
6767
},
6868
},
69+
entity: '',
70+
externalSource: undefined,
71+
multiValueOnGenerator: false,
72+
getExternalSourceByMetadata(metadata): string {
73+
return '';
74+
},
6975
};
7076

7177
const mockVocabularyHierarchical: Vocabulary = {
@@ -83,6 +89,12 @@ describe('DsoEditMetadataAuthorityFieldComponent', () => {
8389
href: 'entries',
8490
},
8591
},
92+
entity: '',
93+
externalSource: undefined,
94+
multiValueOnGenerator: false,
95+
getExternalSourceByMetadata(metadata): string {
96+
return '';
97+
},
8698
};
8799

88100
const mockVocabularySuggester: Vocabulary = {
@@ -100,6 +112,12 @@ describe('DsoEditMetadataAuthorityFieldComponent', () => {
100112
href: 'entries',
101113
},
102114
},
115+
entity: '',
116+
externalSource: undefined,
117+
multiValueOnGenerator: false,
118+
getExternalSourceByMetadata(metadata): string {
119+
return '';
120+
},
103121
};
104122

105123
let editMetadataValue: DsoEditMetadataValue;

src/app/info/end-user-agreement/end-user-agreement.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('EndUserAgreementComponent', () => {
159159
describe('when the user has already accepted the agreement', () => {
160160

161161
beforeEach(() => {
162-
(endUserAgreementService.hasCurrentUserOrCookieAcceptedAgreement as jasmine.Spy).and.returnValue(observableOf(true));
162+
(endUserAgreementService.hasCurrentUserOrCookieAcceptedAgreement as jasmine.Spy).and.returnValue(of(true));
163163
component.ngOnInit();
164164
fixture.detectChanges();
165165
});
@@ -206,7 +206,7 @@ describe('EndUserAgreementComponent', () => {
206206
describe('warning notification logic', () => {
207207
beforeEach(() => {
208208
(endUserAgreementService.hasCurrentUserOrCookieAcceptedAgreement as jasmine.Spy)
209-
.and.returnValue(observableOf(false));
209+
.and.returnValue(of(false));
210210
fixture.detectChanges();
211211
});
212212

@@ -221,7 +221,7 @@ describe('EndUserAgreementComponent', () => {
221221
component.ngOnInit();
222222
(notificationsService.warning as jasmine.Spy).calls.reset();
223223
(endUserAgreementService.hasCurrentUserOrCookieAcceptedAgreement as jasmine.Spy)
224-
.and.returnValue(observableOf(true));
224+
.and.returnValue(of(true));
225225
component.initAccepted();
226226
expect(notificationsService.warning).not.toHaveBeenCalled();
227227
});

0 commit comments

Comments
 (0)