Skip to content

Commit b42f63a

Browse files
author
Andrea Barbasso
committed
[DURACOM-309] fix tests
1 parent 97db9b7 commit b42f63a

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/app/shared/cookies/browser-orejime.service.spec.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('BrowserOrejimeService', () => {
6666
authService = jasmine.createSpyObj('authService', {
6767
isAuthenticated: observableOf(true),
6868
getAuthenticatedUserFromStore: observableOf(user),
69+
getAuthenticatedUserIdFromStore: observableOf(user.id),
6970
});
7071
configurationDataService = createConfigSuccessSpy(recaptchaValue);
7172
findByPropertyName = configurationDataService.findByPropertyName;
@@ -135,6 +136,7 @@ describe('BrowserOrejimeService', () => {
135136

136137
describe('initialize with user', () => {
137138
beforeEach(() => {
139+
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(user.uuid));
138140
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
139141
translateService.get.and.returnValue(observableOf('loading...'));
140142
spyOn(service, 'addAppMessages');
@@ -151,6 +153,7 @@ describe('BrowserOrejimeService', () => {
151153

152154
describe('to not call the initialize user method, but the other methods', () => {
153155
beforeEach(() => {
156+
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(undefined));
154157
spyOn((service as any), 'getUser$').and.returnValue(observableOf(undefined));
155158
translateService.get.and.returnValue(observableOf('loading...'));
156159
spyOn(service, 'addAppMessages');
@@ -202,22 +205,22 @@ describe('BrowserOrejimeService', () => {
202205
});
203206
});
204207

205-
describe('getUser$ when there is no one authenticated', () => {
208+
describe('getUserId$ when there is no one authenticated', () => {
206209
beforeEach(() => {
207210
(service as any).authService.isAuthenticated.and.returnValue(observableOf(false));
208211
});
209212
it('should return undefined', () => {
210-
getTestScheduler().expectObservable((service as any).getUser$()).toBe('(a|)', { a: undefined });
213+
getTestScheduler().expectObservable((service as any).getUserId$()).toBe('(a|)', { a: undefined });
211214
});
212215
});
213216

214-
describe('getUser$ when there someone is authenticated', () => {
217+
describe('getUserId$ when there someone is authenticated', () => {
215218
beforeEach(() => {
216219
(service as any).authService.isAuthenticated.and.returnValue(observableOf(true));
217-
(service as any).authService.getAuthenticatedUserFromStore.and.returnValue(observableOf(user));
220+
(service as any).authService.getAuthenticatedUserIdFromStore.and.returnValue(observableOf(user.id));
218221
});
219-
it('should return the user', () => {
220-
getTestScheduler().expectObservable((service as any).getUser$()).toBe('(a|)', { a: user });
222+
it('should return the user id', () => {
223+
getTestScheduler().expectObservable((service as any).getUserId$()).toBe('(a|)', { a: user.id });
221224
});
222225
});
223226

@@ -242,7 +245,7 @@ describe('BrowserOrejimeService', () => {
242245

243246
describe('when no user is autheticated', () => {
244247
beforeEach(() => {
245-
spyOn(service as any, 'getUser$').and.returnValue(observableOf(undefined));
248+
spyOn(service as any, 'getUserId$').and.returnValue(observableOf(undefined));
246249
});
247250

248251
it('should return the cookie consents object', () => {
@@ -255,7 +258,7 @@ describe('BrowserOrejimeService', () => {
255258

256259
describe('when user is autheticated', () => {
257260
beforeEach(() => {
258-
spyOn(service as any, 'getUser$').and.returnValue(observableOf(user));
261+
spyOn(service as any, 'getUserId$').and.returnValue(observableOf(user.uuid));
259262
});
260263

261264
it('should return the cookie consents object', () => {
@@ -313,7 +316,7 @@ describe('BrowserOrejimeService', () => {
313316
beforeEach(() => {
314317
GOOGLE_ANALYTICS_KEY = clone((service as any).GOOGLE_ANALYTICS_KEY);
315318
REGISTRATION_VERIFICATION_ENABLED_KEY = clone((service as any).REGISTRATION_VERIFICATION_ENABLED_KEY);
316-
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
319+
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(user.uuid));
317320
translateService.get.and.returnValue(observableOf('loading...'));
318321
spyOn(service, 'addAppMessages');
319322
spyOn((service as any), 'initializeUser');

0 commit comments

Comments
 (0)