<commit_before>var chai = require('chai'),
    assert = chai.assert,
    Reflux = require('../src'),
    Q = require('q');

chai.use(require('chai-as-promised'));

describe('Composed listenables', function() {
    var action1,
        action2,
        action3,
        all;

    beforeEach(function() {
        action1 = Reflux.createAction();
        action2 = Reflux.createAction();
        action3 = Reflux.createAction();
        all = Reflux.all(action1, action2, action3);
    });


    it('should emit when all listenables emit', function() {
        var promise = Q.Promise(function(resolve) {
            all.listen(function() {
                resolve(Array.prototype.slice.call(arguments, 0));
            });
        });

        action1('a', 'x');
        action2('b', 'y');
        action3('c', 'z');

        return assert.eventually.deepEqual(promise, [
            ['a', 'x'],
            ['b', 'y'],
            ['c', 'z']
        ]);
    });


    it('should not emit when only one listenable emits', function(done) {
        var called = false;
        all.listen(function() {
            called = true;
        }, null);

        action3('c');

        setTimeout(function() {
            assert.isFalse(called);
            done();
        }, 200);
    });


    it('should not emit when only two listenable emits', function(done) {
        var called = false;
        all.listen(function() {
            called = true;
        }, null);

        action1('a');
        action3('c');

        setTimeout(function() {
            assert.isFalse(called);
            done();
        }, 200);
    });


    it('should emit multiple times', function(done) {
        var callArgs = [];
        all.listen(function() {
            callArgs.push([].slice.call(arguments));
        }, null);

        action1('a');
        action2('b');
        action3('c');

        action1('x');
        action2('y');
        action3('z');

        setTimeout(function() {
            assert.deepEqual(callArgs, [
                [['a'], ['b'], ['c']],
                [['x'], ['y'], ['z']]
            ]);
            done();
        }, 200);
    });


    it('should emit with the last arguments it received', function() {
        var promise = Q.Promise(function(resolve) {
          all.listen(function() {
              resolve(Array.prototype.slice.call(arguments, 0));
          });
        });

        action1('a');
        action2('b');
        action1('x');
        action3('c');

        return assert.eventually.deepEqual(promise, [
          ['x'],
          ['b'],
          ['c']
        ]);
    });
});

describe('Composed listenable with stores', function() {
    var action,<commit_msg>Fix failing tests in Opera and Chrome<commit_after>var chai = require('chai'),
    assert = chai.assert,
    Reflux = require('../src'),
    Q = require('q');

chai.use(require('chai-as-promised'));

describe('Composed listenables', function() {
    var action1,
        action2,
        action3,
        all;

    beforeEach(function() {
        action1 = Reflux.createAction();
        action2 = Reflux.createAction();
        action3 = Reflux.createAction();
        all = Reflux.all(action1, action2, action3);
    });


    it('should emit when all listenables emit', function() {
        var promise = Q.Promise(function(resolve) {
            all.listen(function() {
                resolve(Array.prototype.slice.call(arguments, 0));
            });
        });

        action1('a', 'x');
        action2('b', 'y');
        action3('c', 'z');

        return assert.eventually.deepEqual(promise, [
            ['a', 'x'],
            ['b', 'y'],
            ['c', 'z']
        ]);
    });


    it('should not emit when only one listenable emits', function(done) {
        var called = false;
        all.listen(function() {
            called = true;
        }, null);

        action3('c');

        setTimeout(function() {
            assert.isFalse(called);
            done();
        }, 200);
    });


    it('should not emit when only two listenable emits', function(done) {
        var called = false;
        all.listen(function() {
            called = true;
        }, null);

        action1('a');
        action3('c');

        setTimeout(function() {
            assert.isFalse(called);
            done();
        }, 200);
    });


    it('should emit multiple times', function() {
        var promise = Q.promise(function(resolve) {
            var callArgs = [];
            all.listen(function() {
                callArgs.push([].slice.call(arguments));
                if (callArgs.length === 2) {
                    resolve(callArgs);
                }
            });
        });

        action1('a');
        action2('b');
        action3('c');

        action1('x');
        action2('y');
        action3('z');

        return assert.eventually.deepEqual(promise, [
          [['a'], ['b'], ['c']],
          [['x'], ['y'], ['z']]
        ]);
    });


    it('should emit with the last arguments it received', function() {
        var promise = Q.Promise(function(resolve) {
          all.listen(function() {
              resolve(Array.prototype.slice.call(arguments, 0));
          });
        });

        action1('a');
        action2('b');
        action1('x');
        action3('c');

        return assert.eventually.deepEqual(promise, [
          ['x'],
          ['b'],
          ['c']
        ]);
    });
});

describe('Composed listenable with stores', function() {
    var action,
{'fraction_non_alphanumeric': 0.16865509761388287, 'fraction_numerical': 0.012653651482284888, 'mean_word_length': 1.696393762183236, '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': '7368466', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1549, 'n_words': 321}