mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-309] fix tests
This commit is contained in:

committed by
FrancescoMolinaro

parent
79d03d0433
commit
d423f82324
@@ -67,6 +67,7 @@ describe('BrowserOrejimeService', () => {
|
||||
authService = jasmine.createSpyObj('authService', {
|
||||
isAuthenticated: observableOf(true),
|
||||
getAuthenticatedUserFromStore: observableOf(user),
|
||||
getAuthenticatedUserIdFromStore: observableOf(user.id),
|
||||
});
|
||||
configurationDataService = createConfigSuccessSpy(recaptchaValue);
|
||||
findByPropertyName = configurationDataService.findByPropertyName;
|
||||
@@ -136,6 +137,7 @@ describe('BrowserOrejimeService', () => {
|
||||
|
||||
describe('initialize with user', () => {
|
||||
beforeEach(() => {
|
||||
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(user.uuid));
|
||||
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
|
||||
translateService.get.and.returnValue(observableOf('loading...'));
|
||||
spyOn(service, 'addAppMessages');
|
||||
@@ -152,6 +154,7 @@ describe('BrowserOrejimeService', () => {
|
||||
|
||||
describe('to not call the initialize user method, but the other methods', () => {
|
||||
beforeEach(() => {
|
||||
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(undefined));
|
||||
spyOn((service as any), 'getUser$').and.returnValue(observableOf(undefined));
|
||||
translateService.get.and.returnValue(observableOf('loading...'));
|
||||
spyOn(service, 'addAppMessages');
|
||||
@@ -203,22 +206,22 @@ describe('BrowserOrejimeService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUser$ when there is no one authenticated', () => {
|
||||
describe('getUserId$ when there is no one authenticated', () => {
|
||||
beforeEach(() => {
|
||||
(service as any).authService.isAuthenticated.and.returnValue(observableOf(false));
|
||||
});
|
||||
it('should return undefined', () => {
|
||||
getTestScheduler().expectObservable((service as any).getUser$()).toBe('(a|)', { a: undefined });
|
||||
getTestScheduler().expectObservable((service as any).getUserId$()).toBe('(a|)', { a: undefined });
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUser$ when there someone is authenticated', () => {
|
||||
describe('getUserId$ when there someone is authenticated', () => {
|
||||
beforeEach(() => {
|
||||
(service as any).authService.isAuthenticated.and.returnValue(observableOf(true));
|
||||
(service as any).authService.getAuthenticatedUserFromStore.and.returnValue(observableOf(user));
|
||||
(service as any).authService.getAuthenticatedUserIdFromStore.and.returnValue(observableOf(user.id));
|
||||
});
|
||||
it('should return the user', () => {
|
||||
getTestScheduler().expectObservable((service as any).getUser$()).toBe('(a|)', { a: user });
|
||||
it('should return the user id', () => {
|
||||
getTestScheduler().expectObservable((service as any).getUserId$()).toBe('(a|)', { a: user.id });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -243,7 +246,7 @@ describe('BrowserOrejimeService', () => {
|
||||
|
||||
describe('when no user is autheticated', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service as any, 'getUser$').and.returnValue(observableOf(undefined));
|
||||
spyOn(service as any, 'getUserId$').and.returnValue(observableOf(undefined));
|
||||
});
|
||||
|
||||
it('should return the cookie consents object', () => {
|
||||
@@ -256,7 +259,7 @@ describe('BrowserOrejimeService', () => {
|
||||
|
||||
describe('when user is autheticated', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service as any, 'getUser$').and.returnValue(observableOf(user));
|
||||
spyOn(service as any, 'getUserId$').and.returnValue(observableOf(user.uuid));
|
||||
});
|
||||
|
||||
it('should return the cookie consents object', () => {
|
||||
@@ -316,7 +319,7 @@ describe('BrowserOrejimeService', () => {
|
||||
GOOGLE_ANALYTICS_KEY = clone((service as any).GOOGLE_ANALYTICS_KEY);
|
||||
REGISTRATION_VERIFICATION_ENABLED_KEY = clone((service as any).REGISTRATION_VERIFICATION_ENABLED_KEY);
|
||||
MATOMO_ENABLED = clone((service as any).MATOMO_ENABLED);
|
||||
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
|
||||
spyOn((service as any), 'getUserId$').and.returnValue(observableOf(user.uuid));
|
||||
translateService.get.and.returnValue(observableOf('loading...'));
|
||||
spyOn(service, 'addAppMessages');
|
||||
spyOn((service as any), 'initializeUser');
|
||||
|
Reference in New Issue
Block a user