<commit_before><div id="dom-traverse-container" class="dom-traverse-container">
    <div id="dom-traverse-prev">
        <p class="special"></p>
        <p class="special"></p>
        <p></p>
        <p></p>
        <p class="last"></p>
    </div>
    
    <div id="dom-traverse-next">
        <p></p>
        <p class="first"></p>
        <p></p>
        <p class="special"></p>
        <p></p>
        <p class="special"></p>
        <p></p>
    </div>
    
    <div id="dom-traverse-child">
        <div id="dom-traverse-child-1" class="child-1"></div>
        <div class="special child-1">
            <div class="special child-2">
                <div class="special child-3"></div>
            </div>
        </div>
        <div class="special" class="child-1">
            <div></div>
        </div>
    </div>
    
    <div id="dom-traverse-parent">
        <div class="parent-special">
            <div class="parent-special">
                <div class="parent" class="dom-traverse-grandson">
                    <div id="dom-traverse-grandson" class="dom-traverse-grandson"></div>
                </div>
            </div>
        </div>
    </div>
    
    <div id="dom-traverse-contains">
        <div id="dom-traverse-contains-child"></div>
    </div>
    
    <div id="dom-traverse-contains-subling"></div>
</div>

<script>

describe("Neuron: dom/traverse", function(){

var PREFIX = 'dom-traverse',
    $ = NR.DOM;
    
!$.jq && describe(".prev()", function(){
    it("could get previous subling of the first context: .prev()", function(){
        var last = $('#dom-traverse-prev .last'),
            all_p = $('#dom-traverse-prev p');
        
        expect(last.prev()[0]).toBe(all_p[3]);
    });
    
    it("could get the most preceding adjacent subling who matches the selector: .prev(selector)", function(){
        var last = $('#dom-traverse-prev .last'),
            all_p = $('#dom-traverse-prev p');
        
        expect(last.prev('.special')[0]).toBe(all_p[1]);
    });
});


describe(".prevAll()", function(){
    it("could get all previous sublings: .prevAll()", function(){
        var last = $('#dom-traverse-prev .last');
    
        expect(last.prevAll().length).toBe(4);
    });
    
    it("could get all previous sublings who match the selector: .prevAll(selector)", function(){
        var last = $('#dom-traverse-prev .last');
    
        // only 2 .special
        expect(last.prevAll('.special').length).toBe(2);
    });
    
    it("could prevent duplication", function(){
        var elements = $('#dom-traverse-prev .last').add('#dom-traverse-prev .special');
    
        expect(elements.prevAll().length).toBe(4);
        expect(elements.prevAll('.special').length).toBe(2);
    });
});


!$.jq && describe(".next()", function(){
    it("could get the next subling: .next()", function(){
        var el = $('#dom-traverse-next .first'),
            all_p = $('#dom-traverse-next p');
    
        expect(el.next()[0]).toBe(all_p[2]);
    });
    
    it("could get the most following adjacent subling who matches the selector: .next(selector)", function(){
        var el = $('#dom-traverse-next .first'),
            all_p = $('#dom-traverse-next p');
    
        expect(el.next('.special')[0]).toBe(all_p[3]);
    });
    
});


describe(".nextAll()", function(){
    it("could get all following sublings: .nextAll()", function(){
        var last = $('#dom-traverse-next .first');
    
        expect(last.nextAll().length).toBe(5);
    });
    
    
    it("could get all following sublings who match the selector: .nextAll(selector)", function(){
        var last = $('#dom-traverse-next .first');
    
        expect(last.nextAll('.special').length).toBe(2);
    });
    
    it("could prevent duplication", function(){
        var elements = $('#dom-traverse-next .first').add('#dom-traverse-next .special');
    
        expect(elements.nextAll().length).toBe(5);
        expect(elements.nextAll('.special').length).toBe(2);
    });
});


describe(".child()", function(){
    it("could get the first direct offspring", function(){
        var parent = $('#dom-traverse-child'),
            first_child = $('#dom-traverse-child-1');
    
        expect(parent.child()[0]).toBe(first_child[0]);
    });
    
    it("could get the first matched direct offspring", function(){
        var parent = $('#dom-traverse-child');
    
        expect(parent.child('.special').is('.child-1')).toBe(true);
        expect(parent.child('.special').is('.special')).toBe(true);
    });
});


describe(".children()", function(){
    it("could get all direct offspring", function(){
        expect($('#dom-traverse-child').children().length).toBe(3);
    });
    
    it("could get all direct offspring who match the selector", function(){
        expect($('#dom-traverse-child').children('.special').length).toBe(2);
    });
});


!$.jq && describe(".parent()", function(){
    it("could get the direct parent", function(){
        var son = $('#dom-traverse-grandson');
    
        expect(son.parent().is('.parent')).toBe(true);
    });
    
    it("could fetch the first matched parent", function(){
        var son = $('#dom-traverse-grandson');
    
        expect(son.parent('.parent').is('.parent')).toBe(true);
        expect(son.parent('.parent-special').is('.parent-special')).toBe(true);
        expect( son.parent('.parent-special')[0] ).toBe($('#dom-traverse-parent .parent-special')[1]);
    });
});


describe(".parents()", function(){
    it("could get all matched parents", function(){
        var son = $('#dom-traverse-grandson');<commit_msg>test/unit: dom/traverse: remove test cases of .child()<commit_after><div id="dom-traverse-container" class="dom-traverse-container">
    <div id="dom-traverse-prev">
        <p class="special"></p>
        <p class="special"></p>
        <p></p>
        <p></p>
        <p class="last"></p>
    </div>
    
    <div id="dom-traverse-next">
        <p></p>
        <p class="first"></p>
        <p></p>
        <p class="special"></p>
        <p></p>
        <p class="special"></p>
        <p></p>
    </div>
    
    <div id="dom-traverse-child">
        <div id="dom-traverse-child-1" class="child-1"></div>
        <div class="special child-1">
            <div class="special child-2">
                <div class="special child-3"></div>
            </div>
        </div>
        <div class="special" class="child-1">
            <div></div>
        </div>
    </div>
    
    <div id="dom-traverse-parent">
        <div class="parent-special">
            <div class="parent-special">
                <div class="parent" class="dom-traverse-grandson">
                    <div id="dom-traverse-grandson" class="dom-traverse-grandson"></div>
                </div>
            </div>
        </div>
    </div>
    
    <div id="dom-traverse-contains">
        <div id="dom-traverse-contains-child"></div>
    </div>
    
    <div id="dom-traverse-contains-subling"></div>
</div>

<script>

describe("Neuron: dom/traverse", function(){

var PREFIX = 'dom-traverse',
    $ = NR.DOM;
    
!$.jq && describe(".prev()", function(){
    it("could get previous subling of the first context: .prev()", function(){
        var last = $('#dom-traverse-prev .last'),
            all_p = $('#dom-traverse-prev p');
        
        expect(last.prev()[0]).toBe(all_p[3]);
    });
    
    it("could get the most preceding adjacent subling who matches the selector: .prev(selector)", function(){
        var last = $('#dom-traverse-prev .last'),
            all_p = $('#dom-traverse-prev p');
        
        expect(last.prev('.special')[0]).toBe(all_p[1]);
    });
});


describe(".prevAll()", function(){
    it("could get all previous sublings: .prevAll()", function(){
        var last = $('#dom-traverse-prev .last');
    
        expect(last.prevAll().length).toBe(4);
    });
    
    it("could get all previous sublings who match the selector: .prevAll(selector)", function(){
        var last = $('#dom-traverse-prev .last');
    
        // only 2 .special
        expect(last.prevAll('.special').length).toBe(2);
    });
    
    it("could prevent duplication", function(){
        var elements = $('#dom-traverse-prev .last').add('#dom-traverse-prev .special');
    
        expect(elements.prevAll().length).toBe(4);
        expect(elements.prevAll('.special').length).toBe(2);
    });
});


!$.jq && describe(".next()", function(){
    it("could get the next subling: .next()", function(){
        var el = $('#dom-traverse-next .first'),
            all_p = $('#dom-traverse-next p');
    
        expect(el.next()[0]).toBe(all_p[2]);
    });
    
    it("could get the most following adjacent subling who matches the selector: .next(selector)", function(){
        var el = $('#dom-traverse-next .first'),
            all_p = $('#dom-traverse-next p');
    
        expect(el.next('.special')[0]).toBe(all_p[3]);
    });
    
});


describe(".nextAll()", function(){
    it("could get all following sublings: .nextAll()", function(){
        var last = $('#dom-traverse-next .first');
    
        expect(last.nextAll().length).toBe(5);
    });
    
    
    it("could get all following sublings who match the selector: .nextAll(selector)", function(){
        var last = $('#dom-traverse-next .first');
    
        expect(last.nextAll('.special').length).toBe(2);
    });
    
    it("could prevent duplication", function(){
        var elements = $('#dom-traverse-next .first').add('#dom-traverse-next .special');
    
        expect(elements.nextAll().length).toBe(5);
        expect(elements.nextAll('.special').length).toBe(2);
    });
});


describe(".children()", function(){
    it("could get all direct offspring", function(){
        expect($('#dom-traverse-child').children().length).toBe(3);
    });
    
    it("could get all direct offspring who match the selector", function(){
        expect($('#dom-traverse-child').children('.special').length).toBe(2);
    });
});


!$.jq && describe(".parent()", function(){
    it("could get the direct parent", function(){
        var son = $('#dom-traverse-grandson');
    
        expect(son.parent().is('.parent')).toBe(true);
    });
    
    it("could fetch the first matched parent", function(){
        var son = $('#dom-traverse-grandson');
    
        expect(son.parent('.parent').is('.parent')).toBe(true);
        expect(son.parent('.parent-special').is('.parent-special')).toBe(true);
        expect( son.parent('.parent-special')[0] ).toBe($('#dom-traverse-parent .parent-special')[1]);
    });
});


describe(".parents()", function(){
    it("could get all matched parents", function(){
        var son = $('#dom-traverse-grandson');
{'fraction_non_alphanumeric': 0.20630773537370534, 'fraction_numerical': 0.00541196230288327, 'mean_word_length': 2.4374599101988452, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4873082', 'n_tokens_mistral': 3274, 'n_tokens_neox': 3223, 'n_words': 647}