Skip to content

Commit 59b06a9

Browse files
committed
chore(refactor): Refactor for feature modules
1 parent 94440e5 commit 59b06a9

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

src/app/firebase.app.test.ts

Whitespace-only changes.

src/auth/auth.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { Observer } from 'rxjs/Observer';
66
import { TestBed, inject } from '@angular/core/testing';
77
import { _do } from 'rxjs/operator/do';
88
import { take } from 'rxjs/operator/take';
9-
import 'rxjs/operator/take';
10-
import 'rxjs/operator/do';
9+
import { skip } from 'rxjs/operator/skip';
1110
import { FIREBASE_PROVIDERS, FirebaseApp, FirebaseAppConfig, FirebaseAuthState, FirebaseAppConfigToken, AngularFireAuth, AuthMethods, firebaseAuthConfig, AuthProviders, WindowLocation, AngularFireModule } from '../angularfire2';
1211
import { COMMON_CONFIG, ANON_AUTH_CONFIG } from '../test-config';
1312
import { AuthBackend } from './auth_backend';
@@ -73,6 +72,14 @@ const AngularFireAuthState = {
7372
} as firebase.UserInfo
7473
} as FirebaseAuthState;
7574

75+
function authTake(auth: AngularFireAuth | Observable<any>, count: number): Observable<any> {
76+
return take.call(auth, 1);
77+
}
78+
79+
function authSkip(auth: AngularFireAuth, count: number): Observable<any> {
80+
return skip.call(auth, 1);
81+
}
82+
7683
describe('Zones', () => {
7784
it('should call operators and subscriber in the same zone as when service was initialized', (done) => {
7885
// Initialize the app outside of the zone, to mimick real life behavior.
@@ -83,7 +90,7 @@ describe('Zones', () => {
8390
});
8491
ngZone.run(() => {
8592
var afAuth = new AngularFireAuth(new FirebaseSdkAuthBackend(app), window.location);
86-
var authObs = afAuth.take(1);
93+
var authObs = authTake(afAuth, 1);
8794

8895
_do.call(authObs, _ => {
8996
expect(Zone.current.name).toBe('ngZone');
@@ -176,18 +183,16 @@ describe('FirebaseAuth', () => {
176183
fbAuthObserver.next(null);
177184

178185
// Check that the first value is null
179-
afAuth
180-
.take(1)
186+
take.call(afAuth, 1)
181187
.do((authData) => {
182188
expect(authData).toBe(null);
183189
setTimeout(() => fbAuthObserver.next(firebaseUser));
184190
})
185191
.subscribe();
186192

187193
// Check the 2nd value emitted from the observable
188-
afAuth
189-
.skip(1)
190-
.take(1)
194+
const skipObs = authSkip(afAuth, 1);
195+
take.call(skipObs, 1)
191196
.do((authData) => {
192197
expect(authData.auth).toEqual(AngularFireAuthState.auth);
193198
})
@@ -198,17 +203,15 @@ describe('FirebaseAuth', () => {
198203
describe('AuthState', () => {
199204
it('should asynchronously load firebase auth data', (done) => {
200205
fbAuthObserver.next(firebaseUser);
201-
afAuth
202-
.take(1)
206+
authTake(afAuth, 1)
203207
.subscribe((data) => {
204208
expect(data.auth).toEqual(AngularFireAuthState.auth);
205209
}, done.fail, done);
206210
});
207211

208212
it('should be null if user is not authed', (done) => {
209213
fbAuthObserver.next(null);
210-
afAuth
211-
.take(1)
214+
authTake(afAuth, 1)
212215
.subscribe(authData => {
213216
expect(authData).toBe(null);
214217
}, done.fail, done);
@@ -443,8 +446,7 @@ describe('FirebaseAuth', () => {
443446
});
444447

445448
it('should include credentials in onAuth payload after logging in', (done) => {
446-
afAuth
447-
.take(1)
449+
take.call(afAuth, 1)
448450
.do((user: FirebaseAuthState) => {
449451
expect(user.github).toBe(githubCredential.credential);
450452
})
@@ -460,8 +462,7 @@ describe('FirebaseAuth', () => {
460462

461463
xit('should not call getRedirectResult() if location.protocol is not http or https', (done) => {
462464
windowLocation.protocol = 'file:';
463-
afAuth
464-
.take(1)
465+
take.call(afAuth, 1)
465466
.do(() => {
466467
expect(authSpy['getRedirectResult']).not.toHaveBeenCalled();
467468
})
@@ -500,8 +501,7 @@ describe('FirebaseAuth', () => {
500501

501502
it('should include credentials in onAuth payload after logging in', (done) => {
502503
authSpy['getRedirectResult'].and.returnValue(Promise.resolve(githubCredential));
503-
afAuth
504-
.do((user: FirebaseAuthState) => {
504+
_do.call(afAuth, (user: FirebaseAuthState) => {
505505
expect(user.github).toBe(githubCredential.credential);
506506
})
507507
.take(2)

src/auth/auth_backend.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import * as firebase from 'firebase/app';
2-
import {
3-
authDataToAuthState,
4-
AuthProviders,
5-
FirebaseAuthState
6-
} from './auth_backend';
2+
import { authDataToAuthState, AuthProviders, FirebaseAuthState } from './auth_backend';
73

84
const baseFBUser = {
95
uid: '12345',

src/test-root.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import './angularfire2.spec';
2-
// import './database/firebase_list_factory.spec';
3-
// import './database/firebase_object_factory.spec';
4-
// import './database/firebase_list_observable.spec';
5-
// import './database/firebase_object_observable.spec';
6-
// import './database/query_observable.spec';
2+
import './database/firebase_list_factory.spec';
3+
import './database/firebase_object_factory.spec';
4+
import './database/firebase_list_observable.spec';
5+
import './database/firebase_object_observable.spec';
6+
import './database/query_observable.spec';
77
import './auth/auth.spec';
8-
// import './auth/auth_backend.spec';
8+
import './auth/auth_backend.spec';

0 commit comments

Comments
 (0)