Skip to content

viewDidLeave not subscribable #50

@rob-moore

Description

@rob-moore

Hey I'm working on getting tests up and running for a service that I wrote that uses the App in the constructor.

constructor(public appCtrl: App) {
		this.appCtrl.viewDidLeave.subscribe(view => {
			this.updateHistory(view);
		});
	}

Here's the constructor for the class that I'm testing and here is my test:

describe('tab service', () => {
	let tabSvc: TabService;
	let app: App;

	beforeEach(() => {
		app = AppMock.instance();

		TestBed.configureTestingModule({
			providers: [
				TabService,
			]
		});
		tabSvc = new TabService(app);
	});

	it('should have a updatehistoy method', () => {
		expect(tabSvc.updateHistory).toBe(true);
	});
});

Every time I run the test it seems like it gets to the constructor of my service then it fails with this error:

TypeError: this.appCtrl.viewDidLeave.subscribe is not a function

Any ideas on what's going on here? I looked at the code and it looks like viewDidLeave is available on your AppMock and should always be an Observable. Any idea why I can't subscribe to it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions