-
Notifications
You must be signed in to change notification settings - Fork 1
569 create option users #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d34f7c0
feat: #569 create users and users-list components
PaulRC-ioet e2caaea
feat: #569 create a user store and consume the service of users
PaulRC-ioet e998883
feat: #569 add test for user effects and selectors
PaulRC-ioet 6ad20d6
fix: #569 fix PR comments
PaulRC-ioet 5cc3346
fix: #569 fix PR comments by Rene
PaulRC-ioet f529b3e
fix: #569 remove column switch to admin
PaulRC-ioet 7b637c9
fix: #569 remove container from table
PaulRC-ioet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: #569 add test for user effects and selectors
- Loading branch information
commit e998883c0e2318080c3b6c96b5fae9f5d4b8be24
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { provideMockActions } from '@ngrx/effects/testing'; | ||
| import { Action } from '@ngrx/store'; | ||
| import { Observable, of, throwError } from 'rxjs'; | ||
| import { UsersService } from '../services/users.service'; | ||
| import { UserActionTypes } from './user.actions'; | ||
| import { UserEffects } from './user.effects'; | ||
| import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
| import { ToastrModule, ToastrService } from 'ngx-toastr'; | ||
|
|
||
| describe('UserEffects', () => { | ||
| let actions$: Observable<Action>; | ||
| let effects: UserEffects; | ||
| let service: UsersService; | ||
| let toastrService; | ||
| const user = { id: 'id', name: 'name', email: 'email' }; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| providers: [UserEffects, provideMockActions(() => actions$)], | ||
| imports: [HttpClientTestingModule, ToastrModule.forRoot()], | ||
| declarations: [], | ||
| }); | ||
| effects = TestBed.inject(UserEffects); | ||
| service = TestBed.inject(UsersService); | ||
| toastrService = TestBed.inject(ToastrService); | ||
| }); | ||
|
|
||
| it('should be created', async () => { | ||
| expect(effects).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should return a list of users when the action LOAD_USERS is called', async () => { | ||
PaulRC-ioet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| actions$ = of({ type: UserActionTypes.LOAD_USERS }); | ||
| const serviceSpy = spyOn(service, 'loadUsers'); | ||
| serviceSpy.and.returnValue(of(user)); | ||
|
|
||
| effects.loadUsers$.subscribe((action) => { | ||
| expect(action.type).toEqual(UserActionTypes.LOAD_USERS_SUCCESS); | ||
| }); | ||
| }); | ||
|
|
||
| it('should return an error when the action LOAD_USERS call fails', async () => { | ||
PaulRC-ioet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| actions$ = of({ type: UserActionTypes.LOAD_USERS }); | ||
| const serviceSpy = spyOn(service, 'loadUsers'); | ||
| serviceSpy.and.returnValue(throwError({ error: { message: 'fail!' } })); | ||
| spyOn(toastrService, 'error'); | ||
|
|
||
| effects.loadUsers$.subscribe((action) => { | ||
| expect(toastrService.error).toHaveBeenCalled(); | ||
| expect(action.type).toEqual(UserActionTypes.LOAD_USERS_FAIL); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,10 @@ | ||
| import * as selectors from './user.selectors'; | ||
|
|
||
| describe('UserSelectors', () => { | ||
| it('should select is Loading', () => { | ||
| const isLoadingValue = true; | ||
| const userState = { isLoading: isLoadingValue }; | ||
|
|
||
| expect(selectors.getIsLoading.projector(userState)).toBe(isLoadingValue); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.