<commit_before>var chai = require('chai');
var should = chai.should();
var expect = chai.expect;
var nock = require('nock');

var im = require('./im');
var errors = require('../errors');
var Cache = require('../cache');
var slackTypes = require('./types');


describe('im', function () {



    // function get(name, callback)
    describe('#close', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });

        it('exists as method on im', function (done) {
            expect(typeof im.close).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required string argument', function (done) {

            im.close(null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an error to callback if missing required string argument', function (done) {

            im.close(null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.close')
                .reply(200, { ok: true });

            im.close('channelid', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });


        });
    });

    // function get(name, callback)
    describe('#getList', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });


        it('should throw and error without a valid callback', function (done) {
            expect(function () {
                im.getList(null);
            }).to.throw('callback must be a function');
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.list')
                .reply(200, { ok: true });

            im.getList(function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });


        });
    });

    // function get(name, callback)
    describe('#getHistory', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });


        it('should throw and error without a valid callback', function (done) {
            expect(function () {
                im.getHistory(null);
            }).to.throw('callback must be a function');
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.history')
                .reply(200, { ok: true });

            im.getHistory('channelid', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();<commit_msg>Added test for validation arguments on im.getHistory<commit_after>var chai = require('chai');
var should = chai.should();
var expect = chai.expect;
var nock = require('nock');

var im = require('./im');
var errors = require('../errors');
var Cache = require('../cache');
var slackTypes = require('./types');


describe('im', function () {



    // function get(name, callback)
    describe('#close', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });

        it('exists as method on im', function (done) {
            expect(typeof im.close).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required string argument', function (done) {

            im.close(null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an error to callback if missing required string argument', function (done) {

            im.close(null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.close')
                .reply(200, { ok: true });

            im.close('channelid', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });


        });
    });

    // function get(name, callback)
    describe('#getList', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });


        it('should throw and error without a valid callback', function (done) {
            expect(function () {
                im.getList(null);
            }).to.throw('callback must be a function');
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.list')
                .reply(200, { ok: true });

            im.getList(function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });


        });
    });

    // function get(name, callback)
    describe('#getHistory', function () {

        before(function () {
            var cache = Cache;
            cache.data = {};
            cache.data.hostname = 'slack.com';

        });


        it('should throw and error without a valid callback', function (done) {
            expect(function () {
                im.getHistory(null);
            }).to.throw('callback must be a function');
            done();
        });

        it('should return an error to callback if missing required string argument', function (done) {
            im.getHistory(null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response to caller', function (done) {

            var scope = nock('https://slack.com')
                .post('/api/im.history')
                .reply(200, { ok: true });

            im.getHistory('channelid', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
{'fraction_non_alphanumeric': 0.1506423258958756, 'fraction_numerical': 0.002434077079107505, 'mean_word_length': 1.6310921380291712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '5483364', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1884, 'n_words': 472}