source: Dev/branches/rest-dojo-ui/client/dojo/tests/cache.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.3 KB
Line 
1define(["../main", "doh", "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.