fixed typo in Function::bind[WithArgs] docs
[mootools/dkf.git] / Specs / Plugins / Selectors.Children.js
blob8f7a43c28b88ad59a293e649f3ea3d32721299a6
1 /*
2 Script: Selectors.Children.js
3         Specification Examples of Pseudo Selector :children.
5 License:
6         MIT-style license.
7 */
9 var Container, Children = [];
11 describe('PSeudo Selector :children', {
13         'before all': function(){
14                 Container = new Element('div', {styles: {position: 'absolute', top: 0, left: 0, visibility: 'hidden'}});
15                 (10).times(function(i){
16                         Children.push(new Element('span', {id: 'child-' + i}).set('html', i));
17                 });
18                 Container.adopt(Children).inject(document.body);
19         },
21         'after all': function(){
22                 Container.destroy();
23         },
25         'should use zero-based indexing': function(){
26                 value_of(Container.getElement(':children(0)')).should_be(Children[0]);
27         },
29         'should use negative indexing': function(){
30                 value_of(Container.getElement(':children(-2)')).should_be(Children[8]);
31         },
33         'should return a range of child nodes': function(){
34                 value_of(Container.getElements(':children(0:2)')).should_be(Children.slice(0,3));
35         },
37         'should return a range of child nodes including negative index sorted from first to last node': function(){
38                 var children = Children.slice(0,3).extend(Children.slice(8));
39                 value_of(Container.getElements(':children(-2:2)')).should_be(children);
40                 value_of(Container.getElements(':children(2:-2)')).should_be(Children.slice(2,9));
41         },
43         'should return the node and n-number of child nodes to the right': function(){
44                 value_of(Container.getElements(':children(3+2)')).should_be(Children.slice(3,6));
45         },
47         'should return the node and n-number of child nodes to the right and wrap if necessary and sorting from first to last': function(){
48                 var children = Children.slice(0,3).extend(Children.slice(8));
49                 value_of(Container.getElements(':children(8+4)')).should_be(children);
50         },
52         'should return the node and n-number of child nodes to the left': function(){
53                 value_of(Container.getElements(':children(5-5)')).should_be(Children.slice(0,6));
54         },
56         'should return the node and n-number of child nodes to the left and wrap if necessary and sorting from first to last': function(){
57                 var children = Children.slice(0,3).extend(Children.slice(7));
58                 value_of(Container.getElements(':children(2-5)')).should_be(children);
59         }
61 });