<commit_before>var expect = require('chai').expect,
    sinon = require('sinon'),
    rewire = require("rewire");

var con = rewire("../console/console.js");
//var testGame = rewire('./cartridges/test');
var sandbox = sinon.sandbox.create();
var gameStub = sandbox.stub({
    gameData: {
        commandCounter : 0,
        gameOver : false,
        introText : 'a',
        outroText : 'b',
        player : {},
        map: {}
    },

    gameActions: {}
});

describe('Console', function() {

    before(function() {
        // The before() callback gets run before all tests in the suite. Do one-time setup here.
        //mockery.enable(); // Enable mockery at the start of your test suite
    });

    beforeEach(function() {
        // The beforeEach() callback gets run before each test in the suite.

    });

    afterEach(function() {
        // The beforeEach() callback gets run after each test in the suite.
        sandbox.verifyAndRestore(); // Verify all Sinon mocks have been honored
    });

    after(function() {
        // after() is run after all your tests have completed. Do teardown here.
    });

    describe('input look command', function() {

        //our assertations here

        it('should return successful string', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b'
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1'
            });

            console.log('gamestub',gameStub);

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('look','testGame')).to.equal('b');

            revertTestGame();
        });
    });
});<commit_msg>Added more unit tests for input commands<commit_after>var expect = require('chai').expect,
    sinon = require('sinon'),
    rewire = require("rewire");

var con = rewire("../console/console.js");
//var testGame = rewire('./cartridges/test');
var sandbox = sinon.sandbox.create();
var gameStub = sandbox.stub({
    gameData: {
        commandCounter : 0,
        gameOver : false,
        introText : 'a',
        outroText : 'b',
        player : {},
        map: {}
    },

    gameActions: {}
});

describe('Console', function() {

    before(function() {
        // The before() callback gets run before all tests in the suite. Do one-time setup here.
        //mockery.enable(); // Enable mockery at the start of your test suite
    });

    beforeEach(function() {
        // The beforeEach() callback gets run before each test in the suite.

    });

    afterEach(function() {
        // The beforeEach() callback gets run after each test in the suite.
        sandbox.verifyAndRestore(); // Verify all Sinon mocks have been honored
    });

    after(function() {
        // after() is run after all your tests have completed. Do teardown here.
    });

    //look command should return the current room description
    describe('input look command', function() {

        it('should return b when room is described', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b'
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1'
            });

            console.log('gamestub',gameStub);

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('look','testGame')).to.equal('b');

            revertTestGame();
        });
    });

    //can only take items in the current room
    describe('input take command', function() {

        it('should return c taken', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {
                        c : {
                            displayName : 'c',
                            description : 'd',
                            quantity : 1
                        }
                    }
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : { //inventory object must be set in order for test to work

                }
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('take c','testGame')).to.equal('c taken');

            revertTestGame();
        });
    });

    //use items in inventory or current room
    describe('input use item command', function() {

        it('should return e when used', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {}
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : {
                    c : {
                        displayName : 'c',
                        description : 'd',
                        use: function(){
                            return "e"
                        },
                        quantity : 1
                    }
                }
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('use c','testGame')).to.equal('e');

            revertTestGame();
        });

        it('should return error when c is used - not in inventory', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {
                        c : {
                            displayName : 'c',
                            description : 'd',
                            use: function(){
                                return "e"
                            },
                            quantity : 1
                        }
                    }
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : {}
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('use c','testGame')).to.equal("Can't do that.");

            revertTestGame();
        });
    });

    //interact with items
    describe('input interact item command', function() {

        it('should return error when interacted in inventory', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {}
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : {
                    c : {
                        displayName : 'c',
                        description : 'd',
                        interactions : {
                            interaction1: "e"
                        },
                        quantity : 1
                    }
                }
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('interaction1 c','testGame')).to.equal("I don't know how to do that.");

            revertTestGame();
        });

        it('should return e when interacted - not in inventory', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {
                        c : {
                            displayName : 'c',
                            description : 'd',
                            interactions : {
                                interaction1: "e"
                            },
                            quantity : 1
                        }
                    }
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : {}
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('interaction1 c','testGame')).to.equal('e');

            revertTestGame();
        });
    });

    //can only drop item in player's inventory
    describe('input drop inventory item command', function() {

        it('should return c dropped', function() {

            gameStub.gameData.map = sandbox.stub({

                room1: {
                    firstVisit : true,
                    displayName : 'a',
                    description : 'b',
                    items : {}
                }

            });

            gameStub.gameData.player = sandbox.stub({
                currentLocation : 'room1',
                inventory : {
                    c : {
                        displayName : 'c',
                        description : 'd',
                        quantity : 1
                    }
                }
            });

            var revertTestGame = con.__set__("games", {testGame: gameStub});

            expect(con.input('drop c','testGame')).to.equal('c dropped');

            revertTestGame();
        });
    });
});
{'fraction_non_alphanumeric': 0.11557738572574178, 'fraction_numerical': 0.0028067361668003207, 'mean_word_length': 1.1802884615384615, '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': '5860663', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2367, 'n_words': 592}