<commit_before>var expect = require('chai').expect;
var _ = require('lodash');

var tree = require("../tree-surgeon.js");

describe("Chopping data out of a tree", function() {
    describe("When chopping matching data out of a tree", function() {
        it("should remove all relationships where a matching node is a child", function(){
            var input = {
                "keep" : {
                    "match":"no",
                    "goneChild":{
                        "match":"yes"
                    }
                },
                "gone":{
                    "match":"yes"
                }
            };
            var filter = function(n) { return n.match == "yes"; }

            var expected = {
                "keep":{
                    "match":"no"
                }
            };

            var result = 
                tree.compose(
                    tree.chop(filter,
                        tree.decompose(input)));

            expect(result).to.deep.equal(expected);
        });

        it("should compose to a tree with the matching nodes and their children removed");
        it("should leave non-matching nodes in place, even if they have the same relationship kind");
        it("should chop members of an array independently");
    });
    // plus, chop after
    describe("When chopping after matching data in a tree", function(){
        it("should remove all relationships where a matching node is a parent");
        it("should compose to a tree where matching nodes exist but have no children");
        it("should leave non-matching nodes in place");
        it("should chop members of an array independently");
    });
});<commit_msg>more coverage<commit_after>var expect = require('chai').expect;
var _ = require('lodash');

var tree = require("../tree-surgeon.js");

describe("Chopping data out of a tree", function() {
    describe("When chopping matching data out of a tree", function() {
        it("should remove all relationships where a matching node is a child", function(){
            var input = {
                "Root": "id_0",
                "Nodes": {
                        "id_0": {},
                    "id_1": {
                        "match": "no"
                    },
                    "id_2": {
                        "match": "yes"
                    },
                    "id_3": {
                        "match": "yes"
                    }
                },
                "Relations": [
                    { "Parent": "id_0", "Child": "id_1", "Kind": "keep" },
                    { "Parent": "id_0", "Child": "id_2", "Kind": "gone" },
                    { "Parent": "id_1", "Child": "id_3", "Kind": "goneChild" }
                ]
            };


            var expected = {
                "Root": "id_0",
                "Nodes": {
                    "id_0": {},
                    "id_1": {
                        "match": "no"
                    }
                },
                "Relations": [
                    { "Parent": "id_0", "Child": "id_1", "Kind": "keep" }
                ]
            }
            var filter = function(n) { return n.match == "yes"; }

            var result = tree.chop(filter, input);

            expect(result).to.deep.equal(expected);
         });

        it("should compose to a tree with the matching nodes and their children removed", function(){
            var input = {
                "keep" : {
                    "match":"no",
                    "goneChild":{
                        "match":"yes"
                    }
                },
                "gone":{
                    "match":"yes"
                }
            };
            var filter = function(n) { return n.match == "yes"; }

            var expected = {
                "keep":{
                    "match":"no"
                }
            };

            var result = 
                tree.compose(
                    tree.chop(filter,
                        tree.decompose(input)));

            expect(result).to.deep.equal(expected);
        });

        it("should leave non-matching nodes in place, even if they have the same relationship kind", function(){
            var input = {
                "rel" : {
                    "rel":{
                        "remove":"me"
                    },
                    "but":"not me"
                }
            };
            var expected = {
                "rel" : {
                    "but":"not me"
                }
            };

            var filter = function(n) { return n.remove == "me"; }
            var result = tree.compose(tree.chop(filter, tree.decompose(input)));

            expect(result).to.deep.equal(expected);
        });

        it("should chop members of an array independently", function(){
            var input = {
                "children" : [
                    {"hello":"world"},
                    {"goodbye":"world", "remove":"me"},
                    {"where":"is waldo"},
                    {"sayonara":"sekai", "remove":"me"}
                ]
            };
            var expected = {
                "children" : [
                    {"hello":"world"},
                    {"where":"is waldo"}
                ]
            };

            var filter = function(n) { return n.remove == "me"; }
            var result = tree.compose(tree.chop(filter, tree.decompose(input)));
            expect(result).to.deep.equal(expected);
        });
    });

    describe("When chopping after matching data in a tree", function(){
        it("should remove all relationships where a matching node is a parent");
        it("should compose to a tree where matching nodes exist but have no children");
        it("should leave non-matching nodes in place");
        it("should chop members of an array independently");
    });
});
{'fraction_non_alphanumeric': 0.1302792915531335, 'fraction_numerical': 0.0027247956403269754, 'mean_word_length': 1.1922359089212393, 'pattern_counts': {'":': 54, '<': 3, '<?xml version=': 0, '>': 3, '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': '7204951', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1374, 'n_words': 398}