forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
404ccd9
commit 3e8d180
Showing
8 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Observable } from 'rxjs'; | ||
import { TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { provideMockActions } from '@ngrx/effects/testing'; | ||
import { cold, hot } from 'jasmine-marbles'; | ||
import { MenuEffects } from './menu.effects'; | ||
import { ReinitMenuAction } from './menu.actions'; | ||
import { StoreAction, StoreActionTypes } from '../../store.actions'; | ||
|
||
describe('MenuEffects', () => { | ||
let menuEffects: MenuEffects; | ||
let actions: Observable<any>; | ||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ | ||
MenuEffects, | ||
provideMockActions(() => actions), | ||
], | ||
}); | ||
})); | ||
|
||
beforeEach(() => { | ||
menuEffects = TestBed.inject(MenuEffects); | ||
}); | ||
|
||
describe('reinitDSOMenus', () => { | ||
describe('When a REHYDRATE action is triggered', () => { | ||
let action; | ||
beforeEach(() => { | ||
action = new StoreAction(StoreActionTypes.REHYDRATE, null); | ||
}); | ||
it('should return a ReinitMenuAction', () => { | ||
actions = hot('--a-', {a: action}); | ||
const expected = cold('--b-', {b: new ReinitMenuAction}); | ||
|
||
expect(menuEffects.reinitDSOMenus).toBeObservable(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { map } from 'rxjs/operators'; | ||
import { Injectable } from '@angular/core'; | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
|
||
import { StoreActionTypes } from '../../store.actions'; | ||
import { ReinitMenuAction } from './menu.actions'; | ||
|
||
@Injectable() | ||
export class MenuEffects { | ||
|
||
/** | ||
* When the store is rehydrated in the browser, re-initialise the menus to ensure | ||
* the menus with functions are loaded correctly. | ||
*/ | ||
reinitDSOMenus = createEffect(() => this.actions$ | ||
.pipe(ofType(StoreActionTypes.REHYDRATE), | ||
map(() => new ReinitMenuAction()) | ||
)); | ||
|
||
constructor(private actions$: Actions) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters