feat(aio): replace `take(1)` with more semantic `first()` (#14571)
This commit is contained in:
parent
45eac233eb
commit
c4a6263a01
|
@ -9,7 +9,7 @@ import { of } from 'rxjs/observable/of';
|
|||
import 'rxjs/add/observable/throw';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/delay';
|
||||
import 'rxjs/add/operator/take';
|
||||
import 'rxjs/add/operator/first';
|
||||
|
||||
describe('DocService', () => {
|
||||
let docFetchingService: DocFetchingService;
|
||||
|
@ -31,7 +31,7 @@ describe('DocService', () => {
|
|||
loggerSpy = jasmine.createSpyObj('logger', ['log', 'warn', 'error']);
|
||||
docFetchingService = new DocFetchingService(null, loggerSpy);
|
||||
getFileSpy = spyOn(docFetchingService, 'getDocFile').and
|
||||
.returnValue(of(testDoc).delay(0).take(1)); // take(1) -> completes
|
||||
.returnValue(of(testDoc).delay(0).first()); // first() -> completes
|
||||
|
||||
docService = new DocService(docFetchingService, loggerSpy);
|
||||
});
|
||||
|
|
|
@ -19,12 +19,12 @@ describe('NavMapService', () => {
|
|||
|
||||
beforeEach(done => {
|
||||
httpSpy = jasmine.createSpyObj('http', ['get']);
|
||||
httpSpy.get.and.returnValue(of(getTestNavMapResponse()).delay(0).take(1)); // take(1) -> completes
|
||||
httpSpy.get.and.returnValue(of(getTestNavMapResponse()).delay(0).first()); // first() -> completes
|
||||
loggerSpy = jasmine.createSpyObj('logger', ['log', 'warn', 'error']);
|
||||
|
||||
navMapService = new NavMapService(new DocFetchingService(null, null), httpSpy, loggerSpy);
|
||||
|
||||
navMapService.navMap.take(1).subscribe(
|
||||
navMapService.navMap.first().subscribe(
|
||||
nm => navMap = nm,
|
||||
null,
|
||||
done);
|
||||
|
|
|
@ -51,7 +51,7 @@ describe('SidenavComponent', () => {
|
|||
};
|
||||
|
||||
navEngine = {
|
||||
currentDoc: of(fakeDoc).delay(0).take(1),
|
||||
currentDoc: of(fakeDoc).delay(0).first(),
|
||||
navigate: (docId: string) => { }
|
||||
} as NavEngine;
|
||||
navigateSpy = spyOn(navEngine, 'navigate');
|
||||
|
@ -69,7 +69,7 @@ describe('SidenavComponent', () => {
|
|||
};
|
||||
|
||||
navMapService = {
|
||||
navMap: of(fakeNavMap).delay(0).take(1)
|
||||
navMap: of(fakeNavMap).delay(0).first()
|
||||
} as NavMapService;
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
|
|
|
@ -41,7 +41,7 @@ export class SidenavComponent implements OnInit {
|
|||
// Side effect: when the current doc changes,
|
||||
// get its NavNode and alert the navigation panel
|
||||
this.currentDocId = doc.metadata.docId;
|
||||
this.navMapService.navMap.take(1) // take makes sure it completes!
|
||||
this.navMapService.navMap.first() // take makes sure it completes!
|
||||
.map(navMap => navMap.docs.get(this.currentDocId))
|
||||
.subscribe( node => this.selectedNode.emit(node));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue