<commit_before>'use strict';

var mocha = require('mocha'),
    sinon = require('sinon'),
    expect = require('chai').expect,
    rewire = require('rewire'),
    cache = rewire('../lib/cache');

describe('Cache', function() {
    var redisTransporterMock,
        deferMock;

    beforeEach(function() {
        redisTransporterMock = {
            set: sinon.stub(),
            get: sinon.stub(),
            purge: sinon.stub()
        };
        deferMock = {
            resolve: sinon.stub(),
            reject: sinon.stub()
        };

        cache.__set__('redis', redisTransporterMock);
        cache.__set__('Q', {
            defer: function() {
                return deferMock;
            }
        });
    });

    afterEach(function() {
        cache.__set__('redis', {});
        cache.__set__('Q', {});
    });

    describe('#isTransportAvailable()', function() {
        it('should return false, transport still not set', function() {
            expect(cache.isTransportAvailable()).to.equal(false);
        });

        it('should return true, transport was set', function() {
            cache.setCacheTransporter(redisTransporterMock);

            expect(cache.isTransportAvailable()).to.equal(true);
        });
    });<commit_msg>bug(test): fixed test<commit_after>'use strict';

var mocha = require('mocha'),
    sinon = require('sinon'),
    expect = require('chai').expect,
    rewire = require('rewire'),
    cache = rewire('../lib/cache');

describe('Cache', function() {
    var redisTransporterMock,
        deferMock;

    beforeEach(function() {
        redisTransporterMock = {
            set: sinon.stub(),
            get: sinon.stub(),
            purge: sinon.stub()
        };
        deferMock = {
            resolve: sinon.stub(),
            reject: sinon.stub()
        };

        cache.__set__('redis', redisTransporterMock);
        cache.__set__('Q', {
            defer: function() {
                return deferMock;
            }
        });
    });

    afterEach(function() {
        cache.__set__('redis', {});
        cache.__set__('Q', {});
    });

    describe('#isTransportAvailable()', function() {
        it('should initially return true, as now inMemory caching is enabled by default', function() {
            expect(cache.isTransportAvailable()).to.equal(true);
        });

        it('should return true, transport was set', function() {
            cache.setCacheTransporter(redisTransporterMock);

            expect(cache.isTransportAvailable()).to.equal(true);
        });
    });
{'fraction_non_alphanumeric': 0.15285379202501956, 'fraction_numerical': 0.0, 'mean_word_length': 2.098062953995157, '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': '3261832', 'n_tokens_mistral': 727, 'n_tokens_neox': 709, 'n_words': 129}