1 | define(["../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 | }); |
---|