<commit_before>var chai = require('chai');

var expect = chai.expect,
should = chai.should;

var commandState = require('../lib/command-state.js');
var config = require('../lib/epp-config-devel.json')['nzrs-test1'];

describe('Communication protocol state machine', function() {
    var protocol, stateMachine;
    beforeEach(function() {
        stateMachine = commandState('nzrs-test1', config);
        var connection = stateMachine.connection;
        connection.send = function(xml, callback) {
            callback('<test></test>');
        };
    });
    it('should start out offline', function() {
        expect(stateMachine.state).to.equal('offline');
    });

    describe('registry account logged in', function() {

        beforeEach(function() {
            stateMachine.command('login', {
                "login": "test-user",
                "password": "<PASSWORD>"
            },
            'test-login-1234', function() {
                return {
                    "status": "OK"
                };
            });
        });
        it('should move into idle loop following successful login', function() {
            //expect(stateMachine.connected).to.equal(true);
            expect(stateMachine.state).to.equal('idle');

        });
        it('should throw an error if transactionId not present', function() {

            var testCrash = function() {
                stateMachine.command('logout', {},
                function() {
                    return {
                        "status": "OK"
                    };
                });
            };
            expect(testCrash).to.
            throw ('No transactionId provided');
        });
        it('should be disconnected after logging out', function() {
            stateMachine.command('logout', {},
            'test-logout-1234',

            function() {
                return {
                    "status": "OK"
                };
            });

        });
        it('should execute a specific command and then return to an idle state', function() {
            stateMachine.command('checkDomain', {
                "domain": "test-domain.com"
            },
            'test-checkDomain-1234', function() {
                return {
                    "status": "OK"
                };
            });
            expect(stateMachine.state).to.equal('idle');

        });
    });
});

<commit_msg>test for missing callback fail<commit_after>var chai = require('chai');

var expect = chai.expect,
should = chai.should;

var commandState = require('../lib/command-state.js');
var config = require('../lib/epp-config-devel.json')['nzrs-test1'];

describe('Communication protocol state machine', function() {
    var protocol, stateMachine;
    beforeEach(function() {
        stateMachine = commandState('nzrs-test1', config);
        var connection = stateMachine.connection;
        connection.send = function(xml, callback) {
            callback('<test></test>');
        };
    });
    it('should start out offline', function() {
        expect(stateMachine.state).to.equal('offline');
    });

    describe('registry account logged in', function() {

        beforeEach(function() {
            stateMachine.command('login', {
                "login": "test-user",
                "password": "<PASSWORD>"
            },
            'test-login-1234', function() {
                return {
                    "status": "OK"
                };
            });
        });
        it('should move into idle loop following successful login', function() {
            //expect(stateMachine.connected).to.equal(true);
            expect(stateMachine.state).to.equal('idle');

        });
        it('should throw an error if transactionId not present', function() {

            var testCrash = function() {
                stateMachine.command('logout', {},
                function() {
                    return {
                        "status": "OK"
                    };
                });
            };
            expect(testCrash).to.
            throw ('No transactionId provided');
        });
        it('should throw an error if callback not provided', function() {
            var testCrash = function () {
                stateMachine.command('dosesntMatter', {}, 'test-happiness');
            };
            expect(testCrash).to.throw('Return callback must be a function.');
        });
        it('should be disconnected after logging out', function() {
            stateMachine.command('logout', {},
            'test-logout-1234',
            function() {
                return {
                    "status": "OK"
                };
            });
        });
        it('should execute a specific command and then return to an idle state', function() {
            stateMachine.command('checkDomain', {
                "domain": "test-domain.com"
            },
            'test-checkDomain-1234', function() {
                return {
                    "status": "OK"
                };
            });
            expect(stateMachine.state).to.equal('idle');

        });
    });
});


{'fraction_non_alphanumeric': 0.13987514631291456, 'fraction_numerical': 0.005462348809988295, 'mean_word_length': 1.5854765506807866, 'pattern_counts': {'":': 14, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1956522', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1229, 'n_words': 270}