-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade angular-cli and ngrx versions * Fix new ngrx/store and ngrx/effects * Fix tests
- Loading branch information
Nir Galon
committed
Aug 19, 2017
1 parent
83782aa
commit 2b4d25f
Showing
24 changed files
with
275 additions
and
227 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 |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
npm-debug.log | ||
testem.log | ||
/typings | ||
yarn-error.log | ||
|
||
# e2e | ||
/e2e/*.js | ||
|
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { ClientPage } from './app.po'; | ||
import { AppPage } from './app.po'; | ||
|
||
describe('client App', () => { | ||
let page: ClientPage; | ||
let page: AppPage; | ||
|
||
beforeEach(() => { | ||
page = new ClientPage(); | ||
page = new AppPage(); | ||
}); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,72 @@ | ||
import { TestBed, async, inject } from '@angular/core/testing'; | ||
import { EffectsTestingModule, EffectsRunner } from '@ngrx/effects/testing'; | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
import { provideMockActions } from '@ngrx/effects/testing'; | ||
import { ReplaySubject } from 'rxjs/ReplaySubject'; | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
import { Http, BaseRequestOptions } from '@angular/http'; | ||
import { MockBackend } from '@angular/http/testing'; | ||
|
||
import { UserEffects } from './user'; | ||
import { UserService } from '../services/user.service'; | ||
import { User } from '../models/user'; | ||
import * as userAction from '../actions/user'; | ||
import { UserService } from '../services/user.service'; | ||
|
||
describe('UsersEffects', () => { | ||
const userServiceStub = {}; | ||
let runner: EffectsRunner; | ||
let userEffects: UserEffects; | ||
describe('UserEffects', () => { | ||
let effects: UserEffects; | ||
const actions: Observable<any> = Observable.of(''); | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
EffectsTestingModule, | ||
], | ||
providers: [ | ||
{ provide: UserService, useValue: userServiceStub }, | ||
UserEffects, | ||
] | ||
provideMockActions(() => actions), | ||
// other providers | ||
UserService, | ||
{ | ||
provide: Http, | ||
useFactory: (mockBackend, options) => { | ||
return new Http(mockBackend, options); | ||
}, | ||
deps: [MockBackend, BaseRequestOptions] | ||
}, | ||
MockBackend, | ||
BaseRequestOptions, | ||
], | ||
}); | ||
}); | ||
|
||
beforeEach(inject([ | ||
EffectsRunner, UserEffects | ||
], | ||
(_runner, _userEffects) => { | ||
runner = _runner; | ||
userEffects = _userEffects; | ||
} | ||
)); | ||
effects = TestBed.get(UserEffects); | ||
}); | ||
|
||
it('should create the service', inject([UserEffects], (service: UserEffects) => { | ||
it('should create the effects', inject([UserService], (service: UserService) => { | ||
expect(service).toBeTruthy(); | ||
})); | ||
|
||
it('should return a LOAD_USER_SUCCESS action after LOAD_USER', () => { | ||
runner.queue({ type: 'LOAD_USER' }); | ||
it('loadQuarters$ should work', () => { | ||
const user1 = { | ||
url: 'www.nirgn.com', | ||
username: 'nirgn', | ||
email: 'nirgn@example.com', | ||
groups: [ | ||
'admin' | ||
], | ||
} as User; | ||
const user2 = { | ||
url: 'www.adisaar.com', | ||
username: 'adisaar', | ||
email: 'adisaar@example.com', | ||
groups: [ | ||
'user' | ||
] | ||
} as User; | ||
const users = [user1, user2]; | ||
|
||
const action = new userAction.LoadUserAction(); | ||
const completion = new userAction.LoadUserSuccessAction(users); | ||
const someAction = new ReplaySubject(1); | ||
someAction.next(action); | ||
|
||
userEffects.loadUser$.subscribe(result => { | ||
expect(result).toEqual({ type: 'LOAD_USER_SUCCESS' }); | ||
}); | ||
effects.loadUser$.subscribe(result => { | ||
expect(result).toBe(completion); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.