diff --git a/src/view/view.ts b/src/view/view.ts
index bb3f7bf1f..5bbf5f04e 100644
--- a/src/view/view.ts
+++ b/src/view/view.ts
@@ -185,7 +185,7 @@ export class ViewService {
return () => {
let idx = uiViews.indexOf(uiView);
- if (idx <= 0) {
+ if (idx === -1) {
trace.traceViewServiceUIViewEvent("Tried removing non-registered uiView", uiView);
return;
}
diff --git a/test/core/viewServiceSpec.ts b/test/core/viewServiceSpec.ts
new file mode 100644
index 000000000..f37967fd4
--- /dev/null
+++ b/test/core/viewServiceSpec.ts
@@ -0,0 +1,60 @@
+///
+
+import {UIRouter} from "../../src/router";
+import {tree2Array} from "../testUtils.ts";
+import {StateRegistry} from "../../src/state/stateRegistry";
+import {ViewService} from "../../src/view/view";
+import {ActiveUIView} from "../../src/view/interface";
+
+let router: UIRouter = null;
+let registry: StateRegistry = null;
+let $view: ViewService = null;
+let statetree = {
+ A: {
+ B: {
+ C: {
+ D: {
+
+ }
+ }
+ }
+ }
+};
+
+let count = 0;
+const makeUIView = (): ActiveUIView => ({
+ $type: 'test',
+ id: count++,
+ name: '$default',
+ fqn: '$default',
+ config: null,
+ creationContext: null,
+ configUpdated: function() {}
+});
+
+describe("View Service", () => {
+ beforeEach(() => {
+ router = new UIRouter();
+ registry = router.stateRegistry;
+ $view = router.viewService;
+ tree2Array(statetree, true).forEach(state => registry.register(state));
+ registry.stateQueue.autoFlush(router.stateService);
+ });
+
+ describe('registerUIView', () => {
+ it("should track a ui-view", () => {
+ expect($view.available().length).toBe(0);
+ $view.registerUIView(makeUIView());
+ expect($view.available().length).toBe(1);
+ });
+
+ it("should return a deregistration function", () => {
+ expect($view.available().length).toBe(0);
+ let deregistrationFn = $view.registerUIView(makeUIView());
+ expect(typeof deregistrationFn).toBe('function');
+ expect($view.available().length).toBe(1);
+ deregistrationFn();
+ expect($view.available().length).toBe(0);
+ });
+ });
+});
\ No newline at end of file
diff --git a/test/ng1/viewSpec.ts b/test/ng1/viewSpec.ts
index dcf136178..60a29411b 100644
--- a/test/ng1/viewSpec.ts
+++ b/test/ng1/viewSpec.ts
@@ -1,7 +1,7 @@
-///
-///
-///
-
+///
+///
+///
+import * as angular from "angular";
var module = angular.mock.module;
import {inherit, extend, tail} from "../../src/common/common";
@@ -52,7 +52,7 @@ describe('view', function() {
}));
describe('controller handling', function() {
- let state, path, ctrlExpression;
+ let state, path: PathNode[], ctrlExpression;
beforeEach(() => {
ctrlExpression = null;
state = register({