10 lines
3.6 KiB
JavaScript
10 lines
3.6 KiB
JavaScript
//>>built
|
|
define("dstore/tests/Cache","intern!object intern/chai!assert dojo/Deferred dojo/when dojo/json dojo/aspect dojo/_base/declare dstore/Store dstore/Memory dstore/Request ./mockRequest dstore/Cache".split(" "),function(h,c,t,e,k,p,m,u,l,q,w,r){function f(){return function(){var c=this.inherited(arguments),d=new t;setTimeout(function(){e(c,function(c){d.resolve(c)})});return d.promise}}function n(h,k,g,f){var b;return{setup:function(){var a=[k];f||a.push(r);b=(new m(a))({cachingStore:g,data:[{id:1,name:"one",
|
|
prime:!1},{id:2,name:"two",even:!0,prime:!0},{id:3,name:"three",prime:!0},{id:4,name:"four",even:!0,prime:!1},{id:5,name:"five",prime:!0}]});f&&(b=r.create(b,{cachingStore:g}))},name:h,get:function(){return e(b.get(1)).then(function(a){c.strictEqual(a.name,"one");return g.get(1)}).then(function(a){c.strictEqual(a.name,"one");return b.get(1)}).then(function(a){c.strictEqual(a.name,"one");return b.get(4)}).then(function(a){c.strictEqual(a.name,"four");return g.get(4)}).then(function(a){c.strictEqual(a.name,
|
|
"four");return b.get(4)}).then(function(a){c.strictEqual(a.name,"four")})},filter:function(){b.isLoaded=b.canCacheQuery=function(){return!1};d=!1;var a=b.filter({prime:!0});return e(a.fetch()).then(function(b){c.isTrue(d);c.strictEqual(b.length,3);return a.cachingStore.get(3)}).then(function(v){c.strictEqual(v,void 0);a=b.filter({even:!0});d=!1;a.isLoaded=b.canCacheQuery=function(){return!0};return a.fetch()}).then(function(b){c.isTrue(d);c.strictEqual(b[1].name,"four");a.isValidFetchCache=!0;d=!1;
|
|
return a.fetch()}).then(function(a){c.strictEqual(a.length,2);c.isFalse(d);return b.put({id:6,name:"six",even:!0})}).then(function(){d=!1;return a.fetch()}).then(function(e){c.isFalse(d);c.strictEqual(e.length,3);b.remove(6);b.isValidFetchCache=!1;return a.cachingStore.get(3)})},"filter with sort":function(){return e(b.filter({prime:!0}).sort("name").fetch()).then(function(a){c.strictEqual(a.length,3);return b.filter({even:!0}).sort("name").fetch()}).then(function(a){c.strictEqual(a[1].name,"two")})},
|
|
"put update":function(){return e(b.get(4)).then(function(a){a.square=!0;return b.put(a)}).then(function(){return b.get(4)}).then(function(a){c.isTrue(a.square);return g.get(4)}).then(function(a){c.isTrue(a.square);return b.get(4)}).then(function(a){c.isTrue(a.square)})},"put new":function(){return e(b.put({id:6,perfect:!0})).then(function(){return b.get(6)}).then(function(a){c.isTrue(a.perfect);return g.get(6)}).then(function(a){c.isTrue(a.perfect)})},"add duplicate":function(){return e(b.add({id:6,
|
|
perfect:!0})).then(function(){c.fail("Should not succeed")},function(){})},"add new":function(){return e(b.add({id:7,prime:!0})).then(function(){return b.get(7)}).then(function(a){c.isTrue(a.prime);return g.get(7)}).then(function(a){c.isTrue(a.prime)})},"cached filtered data from all":function(){b.isValidFetchCache=!0;delete b.isLoaded;return e(b.fetch()).then(function(){d=!1;return b.filter({prime:!0}).fetch()}).then(function(a){c.strictEqual(a.length,4);c.isFalse(d)})},"defaults to querier factories of the cachingStore":function(){var a=
|
|
new u;c.isUndefined(a._getQuerierFactory("filter"));var b=function(){},d=r.create(a,{cachingStore:new l({_createFilterQuerier:function(){return b}})}),a=d._getQuerierFactory("filter"),d=d.cachingStore._getQuerierFactory("filter");c.strictEqual(a(),b);c.strictEqual(a(),d())}}}var d;k=m(l,{fetch:function(){d=!0;return this.inherited(arguments)}});p=m(l,{fetch:f(),get:f(),put:f(),remove:f()});q=m([p,k],{});h(n("dstore Cache",k,new l));h(n("dstore create Cache from instance",k,new l,!0));h(n("dstore Cache with async Master",
|
|
q,new l));h(n("dstore Cache with both async",q,new p))});
|
|
//# sourceMappingURL=Cache.js.map
|