Debian Codegraph @

dojox/data/tests/stores/CssRuleStore.js

raw symbols SCIP
1 dojo.provide("dojox.data.tests.stores.CssRuleStore");
2 dojo.require("dojox.data.CssRuleStore");
3 dojo.require("dojo.data.api.Read");
4 dojo.require("dojo.data.api.Identity");
5
6 dojox.data.tests.stores.CssRuleStore.createStore = function(context){
7 // summary:
8 // A simple helper function for getting the sample data used in each of the tests.
9 // description:
10 // A simple helper function for getting the sample data used in each of the tests.
11 var store = null;
12 if(dojo.isBrowser){
13 if(!dojox.data.tests.stores.CssRuleStore._loaded){
14 var head = dojo.doc.getElementsByTagName('head')[0];
15 var link = document.createElement('link');
16 link.href = require.toUrl('dojox/data/tests/stores/test1.css').toString();
17 link.rel = "stylesheet";
18 link.type = "text/css";
19 head.appendChild(link);
20 var style;
21 var text;
22 if(dojo.isIE){
23 style = document.createStyleSheet();
24 style.cssText = '@import "'+require.toUrl('dojox/data/tests/stores/test2.css').toString()+'";';
25 }else{
26 style = document.createElement('style');
27 text = document.createTextNode('@import "'+require.toUrl('dojox/data/tests/stores/test2.css').toString()+'";');
28 style.appendChild(text);
29 head.appendChild(style);
30 }
31 if(dojo.isIE){
32 style = document.createStyleSheet();
33 style.cssText = '.embeddedTestClass { text-align: center; }';
34 }else{
35 style = document.createElement('style');
36 text = document.createTextNode('.embeddedTestClass { text-align: center; }');
37 style.appendChild(text);
38 head.appendChild(style);
39 }
40 dojox.data.tests.stores.CssRuleStore._loaded = true;
41 }
42 store = new dojox.data.CssRuleStore({context: context});
43 }else{
44 // When running tests in Rhino, xhrGet is not available,
45 // so we have the file data in the code below.
46
47 // TODO: What are the stipulations re: DOM ? Can I do the same as above?
48 }
49 return store;
50 } ;
51
52 dojox.data.tests.stores.CssRuleStore.verifyItems = function(cssRuleStore, items, attribute, compareArray){
53 // summary:
54 // A helper function for validating that the items array is ordered
55 // the same as the compareArray
56 if(items.length != compareArray.length){ return false; }
57 for(var i = 0; i < items.length; i++){
58 if(!(cssRuleStore.getValue(items[i], attribute) === compareArray[i])){
59 return false; //Boolean
60 }
61 }
62 return true; //Boolean
63 };
64
65 dojox.data.tests.stores.CssRuleStore.error = function(t, d, errData){
66 // summary:
67 // The error callback function to be used for all of the tests.
68 for (var i in errData) {
69 console.log(errData[i]);
70 }
71 d.errback(errData);
72 };
73
74 doh.register("dojox.data.tests.stores.CssRuleStore",
75 [
76 {
77 name: "testReadAPI_fetch",
78 timeout: 10000, //10 seconds. Flickr can sometimes be slow.
79 runTest: function(t) {
80 // summary:
81 // Simple test of a basic fetch on CssRuleStorem longer timeout because initial load can sometimes take a bit..
82 // description:
83 // Simple test of a basic fetch on CssRuleStorem longer timeout because initial load can sometimes take a bit.
84 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
85
86 var d = new doh.Deferred();
87 function completedAll(items){
88 t.assertTrue(items.length === 3);
89 d.callback(true);
90 }
91
92 //Get everything...
93 cssRuleStore.fetch({
94 query: {'selector': '*TestClass'},
95 onComplete: completedAll,
96 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
97 });
98 return d; //Object
99 }
100 },
101 function testReadAPI_fetch_all(t){
102 // summary:
103 // Simple test of a basic fetch on CssRuleStore.
104 // description:
105 // Simple test of a basic fetch on CssClassStore.
106 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore(['dojox/data/tests/stores/test1.css', 'dojox/data/tests/stores/test2.css']);
107
108 var d = new doh.Deferred();
109 function completedAll(items){
110 t.assertTrue(items.length === 3);
111 d.callback(true);
112 }
113
114 //Get everything...
115 cssRuleStore.fetch({
116 onComplete: completedAll,
117 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
118 });
119 return d; //Object
120 },
121 function testReadAPI_fetch_withinContext(t){
122 // summary:
123 // Simple test of a basic fetch on CssRuleStore.
124 // description:
125 // Simple test of a basic fetch on CssRuleStore.
126
127 //dojox.data.tests.stores.CssRuleStore.loadStylesheets();
128 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore(['dojox/data/tests/stores/test1.css']);
129
130 var d = new doh.Deferred();
131 function completedAll(items){
132 t.assertTrue(items.length === 1);
133 d.callback(true);
134 }
135
136 //Get everything...
137 cssRuleStore.fetch({
138 query: {'selector': '*TestClass'},
139 onComplete: completedAll,
140 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
141 });
142 return d; //Object
143 },
144 function testReadAPI_fetch_withinMultipleSheetContext(t){
145 // summary:
146 // Simple test of a basic fetch on CssRuleStore.
147 // description:
148 // Simple test of a basic fetch on CssRuleStore.
149
150 //dojox.data.tests.stores.CssRuleStore.loadStylesheets();
151 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore(['dojox/data/tests/stores/test1.css', 'dojox/data/tests/stores/test2.css']);
152
153 var d = new doh.Deferred();
154 function completedAll(items){
155 t.assertTrue(items.length === 2);
156 d.callback(true);
157 }
158
159 //Get everything...
160 cssRuleStore.fetch({
161 query: {'selector': '*TestClass'},
162 onComplete: completedAll,
163 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
164 });
165 return d; //Object
166 },
167 function testReadAPI_fetch_switchContext(t){
168 // summary:
169 // Simple test of a basic fetch on CssRuleStore.
170 // description:
171 // Simple test of a basic fetch on CssRuleStore.
172
173 //dojox.data.tests.stores.CssRuleStore.loadStylesheets();
174 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore(['dojox/data/tests/stores/test1.css', 'dojox/data/tests/stores/test2.css']);
175
176 var d = new doh.Deferred();
177 function completedAll(items){
178 t.assertTrue(items.length === 2);
179
180 function completedAllTwo(items){
181 t.assertTrue(items.length === 1);
182 d.callback(true);
183 }
184
185 cssRuleStore.setContext(['dojox/data/tests/stores/test1.css']);
186 cssRuleStore.fetch({
187 query: {'selector': '*TestClass'},
188 onComplete: completedAllTwo,
189 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
190 });
191 }
192
193 //Get everything...
194 cssRuleStore.fetch({
195 query: {'selector': '*TestClass'},
196 onComplete: completedAll,
197 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
198 });
199 return d; //Object
200 },
201 function testReadAPI_fetch_one(t){
202 // summary:
203 // Simple test of a basic fetch on CsvStore of a single item.
204 // description:
205 // Simple test of a basic fetch on CsvStore of a single item.
206 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
207
208 var d = new doh.Deferred();
209 function onComplete(items, request){
210 t.is(1, items.length);
211 d.callback(true);
212 }
213 cssRuleStore.fetch({
214 query: {'selector': '.linkTestClass'},
215 onComplete: onComplete,
216 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
217 });
218 return d; //Object
219 },
220 function testReadAPI_fetch_one_longer(t){
221 // summary:
222 // Simple test of a basic fetch on CsvStore of a single item.
223 // description:
224 // Simple test of a basic fetch on CsvStore of a single item.
225 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
226
227 var d = new doh.Deferred();
228 function onComplete(items, request){
229 t.is(1, items.length);
230 d.callback(true);
231 }
232 cssRuleStore.fetch({
233 query: {'selector': '.linkTestClass .test'},
234 onComplete: onComplete,
235 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
236 });
237 return d; //Object
238 },
239 function testReadAPI_fetch_Multiple(t){
240 // summary:
241 // Simple test of a basic fetch on CsvStore of a single item.
242 // description:
243 // Simple test of a basic fetch on CsvStore of a single item.
244 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
245
246 var d = new doh.Deferred();
247 var done = [false, false];
248
249 function onCompleteOne(items, request){
250 done[0] = true;
251 t.is(1, items.length);
252 if(done[0] && done[1]){
253 d.callback(true);
254 }
255 }
256
257 function onCompleteTwo(items, request){
258 done[1] = true;
259 t.is(1, items.length);
260 if(done[0] && done[1]){
261 d.callback(true);
262 }
263 }
264
265 try{
266 cssRuleStore.fetch({
267 query: {'selector': '.embeddedTestClass'},
268 onComplete: onCompleteOne,
269 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
270 });
271 cssRuleStore.fetch({
272 query: {'selector': '.linkTestClass'},
273 onComplete: onCompleteTwo,
274 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
275 });
276 }catch(e){
277 for(var i in e){
278 console.log(e[i]);
279 }
280 }
281
282 return d; //Object
283 },
284 function testReadAPI_fetch_MultipleMixed(t){
285 // summary:
286 // Simple test of a basic fetch on CsvStore of a single item.
287 // description:
288 // Simple test of a basic fetch on CsvStore of a single item.
289 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
290
291 var d = new doh.Deferred();
292
293 var done = [false, false];
294 function onComplete(items, request){
295 done[0] = true;
296 t.is(1, items.length);
297 t.is('.embeddedTestClass', cssRuleStore.getValue(items[0], 'selector'));
298 if(done[0] && done[1]){
299 d.callback(true);
300 }
301 }
302
303 function onItem(item){
304 done[1] = true;
305 t.assertTrue(item !== null);
306 t.is('.linkTestClass .test', cssRuleStore.getValue(item, 'selector'));
307 if(done[0] && done[1]){
308 d.callback(true);
309 }
310 }
311
312 cssRuleStore.fetch({
313 query: {'selector': '.embeddedTestClass'},
314 onComplete: onComplete,
315 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
316 });
317
318 cssRuleStore.fetch({
319 query: {'selector': '.linkTestClass .test'},
320 onItem: onItem,
321 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
322 });
323 return d; //Object
324 },
325 function testReadAPI_fetch_all_streaming(t){
326 // summary:
327 // Simple test of a basic fetch on CsvStore.
328 // description:
329 // Simple test of a basic fetch on CsvStore.
330 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
331
332 var d = new doh.Deferred();
333 var count = 0;
334
335 function onBegin(size, requestObj){
336 t.assertTrue(size === 3);
337 }
338 function onItem(item, requestObj){
339 t.assertTrue(cssRuleStore.isItem(item));
340 count++;
341 }
342 function onComplete(items, request){
343 t.is(3, count);
344 t.is(null, items);
345 d.callback(true);
346 }
347
348 //Get everything...
349 cssRuleStore.fetch({
350 query: {'selector': '*TestClass'},
351 onBegin: onBegin,
352 onItem: onItem,
353 onComplete: onComplete,
354 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
355 });
356 return d; //Object
357 },
358 function testReadAPI_fetch_paging(t){
359 // summary:
360 // Test of multiple fetches on a single result. Paging, if you will.
361 // description:
362 // Test of multiple fetches on a single result. Paging, if you will.
363 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
364
365 var d = new doh.Deferred();
366
367 function dumpThirdFetch(items, request){
368 t.is(2, items.length);
369 d.callback(true);
370 }
371
372 function dumpSecondFetch(items, request){
373 t.is(1, items.length);
374 t.is('.embeddedTestClass', cssRuleStore.getValue(items[0], 'selector'));
375 request.start = 0;
376 request.count = 2;
377 request.onComplete = dumpThirdFetch;
378 cssRuleStore.fetch(request);
379 }
380
381 function dumpFirstFetch(items, request){
382 t.is(3, items.length);
383 request.start = 2;
384 request.count = 1;
385 request.onComplete = dumpSecondFetch;
386 cssRuleStore.fetch(request);
387 }
388
389
390 cssRuleStore.fetch({
391 query: {'selector': '*TestClass'},
392 onComplete: dumpFirstFetch,
393 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
394 });
395 return d; //Object
396
397 },
398
399 function testReadAPI_getLabel(t){
400 // summary:
401 // Simple test of the getLabel function against a store set that has a label defined.
402 // description:
403 // Simple test of the getLabel function against a store set that has a label defined.
404 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
405
406 var d = new doh.Deferred();
407 function onComplete(items, request){
408 t.assertEqual(items.length, 1);
409 var label = cssRuleStore.getLabel(items[0]);
410 t.assertTrue(label !== null);
411 t.assertEqual(".linkTestClass", label);
412 d.callback(true);
413 }
414 cssRuleStore.fetch({
415 query: {'selector': '.linkTestClass'},
416 onComplete: onComplete,
417 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
418 });
419 return d;
420 },
421 function testReadAPI_getLabelAttributes(t){
422 // summary:
423 // Simple test of the getLabelAttributes function against a store set that has a label defined.
424 // description:
425 // Simple test of the getLabelAttributes function against a store set that has a label defined.
426 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
427
428 var d = new doh.Deferred();
429 function onComplete(items, request){
430 t.assertEqual(items.length, 1);
431 var labelList = cssRuleStore.getLabelAttributes(items[0]);
432 t.assertTrue(dojo.isArray(labelList));
433 t.assertEqual('selector', labelList[0]);
434 d.callback(true);
435 }
436 cssRuleStore.fetch({
437 query: {'selector': '.linkTestClass'},
438 onComplete: onComplete,
439 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
440 });
441 return d;
442 },
443 function testReadAPI_getValue(t){
444 // summary:
445 // Simple test of the getValue function of the store.
446 // description:
447 // Simple test of the getValue function of the store.
448 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
449
450 var d = new doh.Deferred();
451 function onItem(item){
452 t.assertTrue(item !== null);
453 t.is('.linkTestClass', cssRuleStore.getValue(item,'selector'));
454 t.assertTrue(cssRuleStore.getValue(item, 'parentStyleSheetHref').match('dojox/data/tests/stores/test1.css'));
455 d.callback(true);
456 }
457 cssRuleStore.fetch({
458 query: {'selector': '.linkTestClass'},
459 onItem: onItem,
460 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
461 });
462 return d;
463 },
464 function testReadAPI_getValue_2(t){
465 // summary:
466 // Simple test of the getValue function of the store.
467 // description:
468 // Simple test of the getValue function of the store.
469 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
470
471 var d = new doh.Deferred();
472 function onItem(item){
473 t.assertTrue(item !== null);
474 t.is('.importTestClass', cssRuleStore.getValue(item,'selector'));
475 t.assertTrue(cssRuleStore.getValue(item, 'parentStyleSheetHref').match('dojox/data/tests/stores/test2.css'));
476 d.callback(true);
477 }
478 cssRuleStore.fetch({
479 query: {'selector': '.importTestClass'},
480 onItem: onItem,
481 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
482 });
483 return d;
484 },
485 function testReadAPI_getValues(t){
486 // summary:
487 // Simple test of the getValues function of the store.
488 // description:
489 // Simple test of the getValues function of the store.
490 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
491
492 var d = new doh.Deferred();
493 function onItem(item){
494 t.assertTrue(item !== null);
495 var values = cssRuleStore.getValues(item,'selector');
496 t.assertTrue(dojo.isArray(values));
497 t.is(1, values.length);
498 t.is('.embeddedTestClass', values[0]);
499 d.callback(true);
500 }
501 cssRuleStore.fetch({
502 query: {'selector': '.embeddedTestClass'},
503 onItem: onItem,
504 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
505 });
506 return d;
507 },
508 function testReadAPI_isItem(t){
509 // summary:
510 // Simple test of the isItem function of the store
511 // description:
512 // Simple test of the isItem function of the store
513 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
514
515 var d = new doh.Deferred();
516 function onItem(item){
517 t.assertTrue(cssRuleStore.isItem(item));
518 t.assertTrue(!cssRuleStore.isItem({}));
519 t.assertTrue(!cssRuleStore.isItem({ item: "not an item" }));
520 t.assertTrue(!cssRuleStore.isItem("not an item"));
521 t.assertTrue(!cssRuleStore.isItem(["not an item"]));
522 d.callback(true);
523 }
524 cssRuleStore.fetch({
525 query: {'selector': '.embeddedTestClass'},
526 onItem: onItem,
527 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
528 });
529 return d;
530 },
531 function testReadAPI_hasAttribute(t){
532 // summary:
533 // Simple test of the hasAttribute function of the store
534 // description:
535 // Simple test of the hasAttribute function of the store
536 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
537
538 var d = new doh.Deferred();
539 function onItem(item){
540 t.assertTrue(item !== null);
541 t.assertTrue(cssRuleStore.hasAttribute(item, 'selector'));
542 t.assertTrue(cssRuleStore.hasAttribute(item, 'classes'));
543 t.assertTrue(!cssRuleStore.hasAttribute(item, 'Year'));
544 t.assertTrue(!cssRuleStore.hasAttribute(item, 'Nothing'));
545 t.assertTrue(!cssRuleStore.hasAttribute(item, 'title'));
546
547 //Test that null attributes throw an exception
548 var passed = false;
549 try{
550 cssRuleStore.hasAttribute(item, null);
551 }catch (e){
552 passed = true;
553 }
554 t.assertTrue(passed);
555 d.callback(true);
556 }
557 cssRuleStore.fetch({
558 query: {'selector': '.embeddedTestClass'},
559 onItem: onItem,
560 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
561 });
562 return d;
563 },
564 function testReadAPI_containsValue(t){
565 // summary:
566 // Simple test of the containsValue function of the store
567 // description:
568 // Simple test of the containsValue function of the store
569 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
570
571 var d = new doh.Deferred();
572 function onItem(item){
573 t.assertTrue(item !== null);
574 t.assertTrue(cssRuleStore.containsValue(item, 'selector', '.embeddedTestClass'));
575 t.assertTrue(cssRuleStore.containsValue(item, 'classes', '.embeddedTestClass'));
576 t.assertTrue(!cssRuleStore.containsValue(item, 'selector', '.embeddedTestClass2'));
577 t.assertTrue(!cssRuleStore.containsValue(item, 'classes', 'embeddedTestClass '));
578 t.assertTrue(!cssRuleStore.containsValue(item, 'selector', null));
579
580 //Test that null attributes throw an exception
581 var passed = false;
582 try{
583 cssRuleStore.containsValue(item, null, "foo");
584 }catch (e){
585 passed = true;
586 }
587 t.assertTrue(passed);
588 d.callback(true);
589 }
590 cssRuleStore.fetch({
591 query: {'selector': '.embeddedTestClass'},
592 onItem: onItem,
593 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
594 });
595 return d;
596 },
597 function testReadAPI_getAttributes(t){
598 // summary:
599 // Simple test of the getAttributes function of the store
600 // description:
601 // Simple test of the getAttributes function of the store
602 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
603
604 var d = new doh.Deferred();
605 function onItem(item){
606 t.assertTrue(item !== null);
607 t.assertTrue(cssRuleStore.isItem(item));
608
609 var attributes = cssRuleStore.getAttributes(item);
610 t.assertTrue(attributes.length > 8);
611 for(var i = 0; i < 8; i++){
612 var a = attributes[i];
613 t.assertTrue(( a === 'selector' || a === 'classes'
614 || a === 'rule' || a === 'style'
615 || a === 'cssText' || a === 'styleSheet'
616 || a === 'parentStyleSheet' || a === 'parentStyleSheetHref'));
617 }
618 d.callback(true);
619 }
620 cssRuleStore.fetch({
621 query: {'selector': '.embeddedTestClass'},
622 onItem: onItem,
623 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
624 });
625 return d;
626 },
627 function testReadAPI_getFeatures(t){
628 // summary:
629 // Simple test of the getFeatures function of the store
630 // description:
631 // Simple test of the getFeatures function of the store
632 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
633
634 var features = cssRuleStore.getFeatures();
635 var count = 0;
636 for(var i in features){
637 t.assertTrue(i === "dojo.data.api.Read");
638 count++;
639 }
640 t.assertTrue(count === 1);
641 },
642 function testReadAPI_fetch_patternMatch(t){
643 // summary:
644 // Function to test pattern matching of everything swith Cla in it
645 // description:
646 // Function to test pattern matching of everything with Cla in it
647 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
648 var d = new doh.Deferred();
649 function completed(items, request){
650 t.is(4, items.length);
651 var valueArray = ['.linkTestClass', '.linkTestClass .test', '.importTestClass', '.embeddedTestClass'];
652 t.assertTrue(dojox.data.tests.stores.CssRuleStore.verifyItems(cssRuleStore, items, 'selector', valueArray));
653 d.callback(true);
654 }
655
656 cssRuleStore.fetch({
657 query: {'selector': '*TestCla*'},
658 onComplete: completed,
659 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
660 });
661 return d; //Object
662 },
663 function testReadAPI_fetch_patternMatch_caseInsensitive(t){
664 // summary:
665 // Function to test exact pattern match with case insensitivity set.
666 // description:
667 // Function to test exact pattern match with case insensitivity set.
668 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
669 var d = new doh.Deferred();
670 function completed(items, request){
671 t.is(1, items.length);
672 t.assertTrue(cssRuleStore.getValue(items[0], 'selector') === '.linkTestClass');
673 d.callback(true);
674 }
675
676 cssRuleStore.fetch({
677 query: {'selector': '.LINKtEsTclass'},
678 queryOptions: {ignoreCase: true},
679 onComplete: completed,
680 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
681 });
682 return d; //Object
683 },
684 function testReadAPI_fetch_patternMatch_caseSensitive(t){
685 // summary:
686 // Function to test exact pattern match with case insensitivity set.
687 // description:
688 // Function to test exact pattern match with case insensitivity set.
689 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
690 var d = new doh.Deferred();
691 function completed(items, request){
692 t.is(0, items.length);
693 d.callback(true);
694 }
695
696 cssRuleStore.fetch({
697 query: {'selector': '.LINKtEsTclass'},
698 queryOptions: {ignoreCase: false},
699 onComplete: completed,
700 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
701 });
702 return d; //Object
703 },
704 function testReadAPI_fetch_sortAlphabetic(t){
705 // summary:
706 // Function to test sorting alphabetic ordering.
707 // description:
708 // Function to test sorting alphabetic ordering.
709 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
710 var d = new doh.Deferred();
711 function completed(items, request){
712 //Output should be in this order...
713 var orderedArray = [ '.embeddedTestClass',
714 '.importTestClass',
715 '.linkTestClass'
716 ];
717 t.is(3, items.length);
718 t.assertTrue(dojox.data.tests.stores.CssRuleStore.verifyItems(cssRuleStore, items, 'selector', orderedArray));
719 d.callback(true);
720 }
721
722 var sortAttributes = [{attribute: 'selector'}];
723 cssRuleStore.fetch({
724 query: {'selector': '*TestClass'},
725 sort: sortAttributes,
726 onComplete: completed,
727 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
728 });
729 return d; //Object
730 },
731 function testReadAPI_fetch_sortAlphabeticDescending(t){
732 // summary:
733 // Function to test sorting alphabetic ordering in descending mode.
734 // description:
735 // Function to test sorting alphabetic ordering in descending mode.
736 var cssRuleStore = dojox.data.tests.stores.CssRuleStore.createStore();
737 var d = new doh.Deferred();
738
739
740 function completed(items, request){
741 //Output should be in this order...
742 var orderedArray = [ '.linkTestClass',
743 '.importTestClass',
744 '.embeddedTestClass'
745 ];
746
747 t.is(3, items.length);
748 t.assertTrue(dojox.data.tests.stores.CssRuleStore.verifyItems(cssRuleStore, items, 'selector', orderedArray));
749 d.callback(true);
750 }
751
752 var sortAttributes = [{attribute: "selector", descending: true}];
753 cssRuleStore.fetch({
754 query: {'selector': '*TestClass'},
755 sort: sortAttributes,
756 onComplete: completed,
757 onError: dojo.partial(dojox.data.tests.stores.CssRuleStore.error, t, d)
758 });
759 return d; //Object
760 },
761 function testReadAPI_functionConformance(t){
762 // summary:
763 // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
764 // description:
765 // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
766 var testStore = dojox.data.tests.stores.CssRuleStore.createStore();
767 var readApi = new dojo.data.api.Read();
768 var passed = true;
769
770 for(var i in readApi){
771 if(i.toString().charAt(0) !== '_')
772 {
773 var member = readApi[i];
774 //Check that all the 'Read' defined functions exist on the test store.
775 if(typeof member === "function"){
776 console.log("Looking at function: [" + i + "]");
777 var testStoreMember = testStore[i];
778 if(!(typeof testStoreMember === "function")){
779 console.log("Problem with function: [" + i + "]. Got value: " + testStoreMember);
780 passed = false;
781 break;
782 }
783 }
784 }
785 }
786 t.assertTrue(passed);
787 }
788 ]
789 );
790