<commit_before>const Chain = require('../chain/Chain')
const createChain = require('../chain/createChain')
const snion = require('sinon')
const assert = require('chai').assert
describe('Chain', function () {
    describe('#passRequest()', function () {
        it('should call with chain', function () {
            const stub1 = snion.stub().returns(Chain.nextSuccessor)
            const stub2 = snion.stub().returns(Chain.nextSuccessor)
            const stub3 = snion.stub().returnsArg(1)
            const chain1 = new Chain(stub1)
            const chain2 = new Chain(stub2)
            const chain3 = new Chain(stub3)
            chain1.setNextSuccessor(chain2).setNextSuccessor(chain3)
            assert.equal(chain1.passRequest(1, 3), 3)
        })
    })
    describe('#next()', function () {
        it('should call with next when async', function (done) {
            const stub1 = snion.stub().returns(Chain.nextSuccessor)
            const stub2 = function (...args) {
                const self = this
                setTimeout(function () {
                    self.next(...args)
                }, 1)
            }
            const stub3 = snion.stub().returns(Chain.nextSuccessor)
            const chain1 = new Chain(stub1)
            const chain2 = new Chain(stub2)
            const chain3 = new Chain(stub3)
            chain1.setNextSuccessor(chain2).setNextSuccessor(chain3).setNextSuccessor(new Chain(function (...args) {
                assert.deepEqual(args, [1, 3])
                done()
            }))
            chain1.passRequest(1, 3)
        })
    })
})
describe('chain', function () {
    it('should call with chain', function () {
        const stub1 = snion.stub().returns(createChain.nextSuccessor)
        const stub2 = snion.stub().returns(createChain.nextSuccessor)
        const stub3 = snion.stub().returnsArg(1)
        const chain = createChain(createChain(stub1, stub2), stub3)
        const ret = chain(1, 3)
        assert.equal(ret, 3)
    })
})<commit_msg>cover<commit_after>const Chain = require('../chain/Chain')
const createChain = require('../chain/createChain')
const snion = require('sinon')
const assert = require('chai').assert
describe('Chain', function () {
    describe('#passRequest()', function () {
        it('should call with chain', function () {
            const stub1 = snion.stub().returns(Chain.nextSuccessor)
            const stub2 = snion.stub().returns(Chain.nextSuccessor)
            const stub3 = snion.stub().returnsArg(1)
            const chain1 = new Chain(stub1)
            const chain2 = new Chain(stub2)
            const chain3 = new Chain(stub3)
            chain1.setNextSuccessor(chain2).setNextSuccessor(chain3)
            assert.equal(chain1.passRequest(1, 3), 3)
        })
    })
    describe('#next()', function () {
        it('should call with next when async', function (done) {
            const stub1 = snion.stub().returns(Chain.nextSuccessor)
            const stub2 = function (...args) {
                const self = this
                setTimeout(function () {
                    self.next(...args)
                }, 1)
            }
            const stub3 = snion.stub().returns(Chain.nextSuccessor)
            const chain1 = new Chain(stub1)
            const chain2 = new Chain(stub2)
            const chain3 = new Chain(stub3)
            chain1.setNextSuccessor(chain2).setNextSuccessor(chain3).setNextSuccessor(new Chain(function (...args) {
                assert.deepEqual(args, [1, 3])
                done()
            }))
            chain1.passRequest(1, 3)
        })
    })
})
describe('chain', function () {
    it('should call with chain', function () {
        const stub1 = snion.stub().returns(createChain.nextSuccessor)
        const stub2 = snion.stub().returns(createChain.nextSuccessor)
        const stub3 = snion.stub().returnsArg(1)
        const chain = createChain(createChain(stub1, stub2), stub3)
        const ret = chain(1, 3)
        assert.equal(ret, 3)
        const otherChain = createChain(createChain(stub3, stub2), stub1)
        const otherRet = otherChain(1, 3)
        assert.equal(otherRet, 3)
    })
})
{'fraction_non_alphanumeric': 0.12982961363090953, 'fraction_numerical': 0.023038156947444204, 'mean_word_length': 2.164768413059985, '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': '6770896', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1192, 'n_words': 251}