-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(viewService): Allow root ui-view to be wrapped in ng-if
Fixed an off-by-one error in viewService which caused the root ui-view to not be deregistered properly. Closes #3004
- Loading branch information
1 parent
5a12f92
commit 32f718a
Showing
3 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/// <reference path='../../node_modules/@types/jasmine/index.d.ts' /> | ||
|
||
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters