<commit_before>describe('Local', function () {

    it('should listen to a local event', function () {
        var local = new join.Local("local");
        var count = 0;
        var data;
        local.on('local', function (d) {
            count++;
            data = d;
        });
        local.local();
        expect(count).toBe(1);
        expect(data).toBe(local);
    });

    it('should listen to a remote event', function () {
        var local = new join.Local();
        var remote = new join.Remote(0, 'remote');
        var count = 0;
        var data;
        local.on('remote', function (remote) {
            count++;
            data = remote;
        });
        local.remote(remote);
        expect(count).toBe(1);
        expect(data).toBe(remote);
    });

    it('should listen to a stream event', function () {
        var local = new join.Local();
        var stream = {};
        var count = 0;
        var data;
        local.on('stream', function (stream) {
            count++;
            data = stream;
        });
        local.stream(stream);
        expect(count).toBe(1);
        expect(data).toBe(stream);
    });

    it('should listen to a bundle event', function () {
        var local = new join.Local();
        var bundle = new join.ChannelBundle('chat', local, function() {});
        var count = 0;
        var data;
        local.on('chat.channel', function (bundle) {
            count++;
            data = bundle;
        });
        local.bundle(bundle);
        expect(count).toBe(1);
        expect(data).toBe(bundle);
    });

    it('should listen to a close event', function () {
        var local = new join.Local();
        var count = 0;
        var data;
        local.on('close', function () {
            count++;
        });
        local.close();
        expect(count).toBe(1);
    });

});<commit_msg>Use spy objects<commit_after>describe('Peer', function () {

    describe('Local', function () {
        it('should listen to a local event', function () {
            var spy = jasmine.createSpy('spy');

            var local = new join.Local('local');
            local.on('local', spy);
            local.local();

            expect(spy).toHaveBeenCalledWith(local);
        });

        it('should listen to a remote event', function () {
            var spy = jasmine.createSpy('spy');

            var local = new join.Local();
            local.on('remote', spy);
            var remote = new join.Remote(0, 'remote');
            local.remote(remote);

            expect(spy).toHaveBeenCalledWith(remote);
        });

        it('should listen to a stream event', function () {
            var spy = jasmine.createSpy('spy');

            var local = new join.Local();
            var stream = {};
            local.on('stream', spy);
            local.stream(stream);

            expect(spy).toHaveBeenCalledWith(stream);
        });

        it('should listen to a bundle event', function () {
            var spy = jasmine.createSpy('spy');

            var local = new join.Local();
            var bundle = new join.ChannelBundle('chat', local, function() {});
            local.on('chat.channel', spy);
            local.bundle(bundle);

            expect(spy).toHaveBeenCalledWith(bundle);
        });

        it('should listen to a close event', function () {
            var spy = jasmine.createSpy('spy');

            var local = new join.Local();
            local.onclose = spy;
            local.close();

            expect(spy).toHaveBeenCalled();
        });

    });

    describe('Remote', function () {

        it('should listen to a close event', function () {
            var spy = jasmine.createSpy('spy');

            var remote = new join.Remote(0, 'remote');
            remote.onclose = spy;
            remote.close();

            expect(spy).toHaveBeenCalled();
        });

        it('should listen to a stream event', function () {
            var spy = jasmine.createSpy('spy');

            var remote = new join.Remote(0, 'remote');
            var stream = {};
            remote.on('stream', spy);
            remote.stream(stream);

            expect(spy).toHaveBeenCalledWith(stream);
        });

    });

});
{'fraction_non_alphanumeric': 0.14626654064272213, 'fraction_numerical': 0.0033081285444234404, 'mean_word_length': 1.7082533589251438, 'pattern_counts': {'":': 0, '<': 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': '7614106', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1127, 'n_words': 287}