This repository has been archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ViewCache): Use an unbounded cache in the ViewCache.
ViewCache was broken by the LruCache change in 3e60863. Between that change and this one, it was not caching any views. Also, add a test.
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
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,36 @@ | ||
library angular.dom.view_cache_spec; | ||
|
||
import '../_specs.dart'; | ||
|
||
main() { | ||
describe('ViewCache', () { | ||
var HTML = '<div>html</div>'; | ||
var mockCompiler; | ||
beforeEachModule((Module module) { | ||
var httpBackend = new MockHttpBackend(); | ||
|
||
module | ||
..bind(HttpBackend, toValue: httpBackend) | ||
..bind(MockHttpBackend, toValue: httpBackend); | ||
}); | ||
|
||
it('should cache the ViewFactory', async(( | ||
ViewCache cache, MockHttpBackend backend, DirectiveMap directives) { | ||
var firstFactory = cache.fromHtml(HTML, directives); | ||
|
||
expect(cache.fromHtml(HTML, directives)).toBe(firstFactory); | ||
|
||
// Also for fromUrl | ||
backend.whenGET('template.url').respond(200, HTML); | ||
|
||
var httpFactory; | ||
cache.fromUrl('template.url', directives).then((f) => httpFactory = f); | ||
|
||
microLeap(); | ||
backend.flush(); | ||
microLeap(); | ||
|
||
expect(httpFactory).toBe(firstFactory); | ||
})); | ||
}); | ||
} |