Skip to content

Commit 8076593

Browse files
committed
fix(ViewController, NavController): Remove Circular references in View and NavControllerMocks
Issue-20
1 parent b42a361 commit 8076593

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/angular/nav-controller.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {ViewControllerMock} from './view-controller';
21
import {Observable} from 'rxjs/Observable';
32

43
export class NavControllerMock {
@@ -54,7 +53,7 @@ export class NavControllerMock {
5453
instance.goToRoot.and.returnValue(Promise.resolve());
5554
instance.initPane.and.returnValue(1);
5655

57-
instance['root'] = ViewControllerMock.instance();
56+
instance['root'] = {};
5857
instance['rootParams'] = {};
5958

6059
instance.push.and.returnValue(Promise.resolve());
@@ -72,12 +71,12 @@ export class NavControllerMock {
7271
instance.canSwipeBack.and.returnValue(true);
7372
instance.canGoBack.and.returnValue(true);
7473
instance.isTransitioning.and.returnValue(false);
75-
instance.getActive.and.returnValue(ViewControllerMock.instance());
74+
instance.getActive.and.returnValue({});
7675
instance.isActive.and.returnValue(true);
77-
instance.getByIndex.and.returnValue(ViewControllerMock.instance());
78-
instance.getPrevious.and.returnValue(ViewControllerMock.instance());
79-
instance.first.and.returnValue(ViewControllerMock.instance());
80-
instance.last.and.returnValue(ViewControllerMock.instance());
76+
instance.getByIndex.and.returnValue({});
77+
instance.getPrevious.and.returnValue({});
78+
instance.first.and.returnValue({});
79+
instance.last.and.returnValue({});
8180
instance.indexOf.and.returnValue(0);
8281
instance.length.and.returnValue(0);
8382
instance.getViews.and.returnValue([]);

src/angular/view-controller.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import {Observable} from 'rxjs';
22
import {NavParamsMock} from './nav-params';
3-
import {NavControllerMock} from './nav-controller';
43

54
export class ViewControllerMock {
6-
private static staticInstance: null;
75

86
public static instance(): any {
9-
if(ViewControllerMock.staticInstance == null) {
107
let instance = jasmine.createSpyObj('ViewController', [
118
'willEnter',
129
'didEnter',
@@ -61,7 +58,7 @@ export class ViewControllerMock {
6158
instance.hasNavbar.and.returnValue(true);
6259
instance.index.and.returnValue(true);
6360
instance.subscribe.and.returnValue(Observable.of({}));
64-
instance.getNav.and.returnValue(NavControllerMock.instance());
61+
instance.getNav.and.returnValue({});
6562
instance.getIONContent.and.returnValue({});
6663

6764
instance['writeReady'] = {
@@ -87,9 +84,6 @@ export class ViewControllerMock {
8784
instance['instance'] = {};
8885
instance['id'] = '';
8986

90-
ViewControllerMock.staticInstance = instance;
91-
}
92-
93-
return ViewControllerMock.staticInstance;
87+
return instance;
9488
}
9589
}

0 commit comments

Comments
 (0)