source: Dev/trunk/src/client/dojo/tests/cache.js @ 485

Last change on this file since 485 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.3 KB
Line 
1define(["../main", "doh/main", "require", "../cache", "../_base/url"], function(dojo, doh, require){
2        doh.register("tests.cache", [{
3                        name: "dojo.cache",
4                        runTest: function(t){
5                                var expected = "<h1>Hello World</h1>";
6
7                                t.is(expected, dojo.trim(dojo.cache("dojo.tests.cache", "regular.html")));
8                                t.is(expected, dojo.trim(dojo.cache("dojo.tests.cache", "sanitized.html", {sanitize: true})));
9
10                                //Test object variant for module.
11                                var objPath = require.toUrl("dojo/tests/cache/object.html");
12                                t.is(expected, dojo.trim(dojo.cache(new dojo._Url(objPath), {sanitize: true})));
13
14                                //Just a couple of other passes just to make sure on manual inspection that the
15                                //files are loaded over the network only once.
16                                t.is(expected, dojo.trim(dojo.cache("dojo.tests.cache", "regular.html")));
17                                t.is(expected, dojo.trim(dojo.cache("dojo.tests.cache", "sanitized.html", {sanitize: true})));
18                                t.is(expected, dojo.trim(dojo.cache(new dojo._Url(objPath), {sanitize: true})));
19
20                                //Make sure unset cache does not throw errors
21                                t.is(null, dojo.cache("dojo.tests.cache", "regular.html", null));
22
23                                //Set empty string as value
24                                t.is("", dojo.cache("dojo.tests.cache", "regular.html", ""));
25                                t.is("", dojo.cache("dojo.tests.cache", "regular.html"));
26                        }
27                }
28        ]);
29});
Note: See TracBrowser for help on using the repository browser.