-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store): make reducers accessible from ReducerManager (#3064)
* feat(reducer-manager): permit to access reducers * ref: rename reducerSnapshot to currentReducers * test: apply check if getter for currentReducers works as expected
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { createReducer, ReducerManager, StoreModule } from '@ngrx/store'; | ||
|
||
describe(ReducerManager.name, () => { | ||
it('should provide reducers being registered in store', () => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
StoreModule.forRoot({ | ||
'feature-1': createReducer(0), | ||
}), | ||
], | ||
}); | ||
|
||
const reducerManager = TestBed.inject(ReducerManager); | ||
|
||
expect(Object.keys(reducerManager.currentReducers)).toContain('feature-1'); | ||
}); | ||
|
||
it('should provide reducers being registered at runtime', () => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
StoreModule.forRoot({ | ||
'feature-1': createReducer(0), | ||
}), | ||
], | ||
}); | ||
|
||
const reducerManager = TestBed.inject(ReducerManager); | ||
|
||
reducerManager.addReducer('feature-2', createReducer(0)); | ||
|
||
expect(Object.keys(reducerManager.currentReducers)).toContain('feature-1'); | ||
expect(Object.keys(reducerManager.currentReducers)).toContain('feature-2'); | ||
}); | ||
}); |
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