<commit_before>var test = require('tap').test;
var trumpet = require('../');
var fs = require('fs');

test('update', function (t) {
    t.plan(6);
    var html = fs.readFileSync(__dirname + '/update_target.html', 'utf8');
    
    var tr = trumpet();
    fs.createReadStream(__dirname + '/update.html').pipe(tr);
    
    var spans = [ 'tacos', 'y', 'burritos' ];
    
    tr.update('.b span', function (html, node) {
        t.equal(node.name, 'span');
        t.same(node.attributes, { class : 'b' });
        return html.toUpperCase();
    });
    
    tr.update('.c', '---');
    tr.remove('.d');
    tr.remove('.e');
    tr.replace('.f', '<b>NOTHING TO SEE HERE</b>');
    
    tr.replace('.g', function (html, node) {
        t.equal(node.name, 'div');
        t.equal(html, '<div class="g">EVERYTHING IS TERRIBLE</div>');
        return '<blink>TERRIBLE</blink>';
    });
    
    var data = '';
    tr.on('data', function (buf) { data += buf });
    
    tr.on('end', function () {
        t.equal(data, html);
    });
});<commit_msg>fix error in short update test<commit_after>var test = require('tap').test;
var trumpet = require('../');
var fs = require('fs');

test('update', function (t) {
    t.plan(6);
    var html = fs.readFileSync(__dirname + '/update_target.html', 'utf8');
    
    var tr = trumpet();
    fs.createReadStream(__dirname + '/update.html').pipe(tr);
    
    var spans = [ 'tacos', 'y', 'burritos' ];
    
    tr.update('.b span', function (html, node) {
        t.equal(node.name, 'span');
        return html.toUpperCase();
    });
    
    tr.update('.c', '---');
    tr.remove('.d');
    tr.remove('.e');
    tr.replace('.f', '<b>NOTHING TO SEE HERE</b>');
    
    tr.replace('.g', function (html, node) {
        t.equal(node.name, 'div');
        t.same(node.attributes, { class : 'g' });
        t.equal(html, '<div class="g">EVERYTHING IS TERRIBLE</div>');
        return '<blink>TERRIBLE</blink>';
    });
    
    var data = '';
    tr.on('data', function (buf) { data += buf });
    
    tr.on('end', function () {
        t.equal(data, html);
    });
});
{'fraction_non_alphanumeric': 0.2237029985721085, 'fraction_numerical': 0.0019038553069966682, 'mean_word_length': 2.4686468646864688, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6847153', 'n_tokens_mistral': 746, 'n_tokens_neox': 733, 'n_words': 149}