<commit_before>var steam = require("steam"),
	dota2 = require("../"),
	steamClient = new steam.SteamClient(),
	steamUser = new steam.SteamUser(steamClient),
	Dota2 = new dota2.Dota2Client(steamClient, true, true),
	should = require('should');
	
	// Test data
	var GABE_STEAM_ID = '76561197960287930',
	GABE_ACCOUNT_ID = '22202';
    
	// App states, will be used to delay certain tests until conditions are met.
	var connectedToSteam = false,
		loggedInToSteam = false,
		connectedToDota2 = false;
	
	// Delays for certain states
	var beConnectedToSteam = function(done) {
		if (connectedToSteam) {
			return done();
		}
		
		setTimeout(function() {
			beConnectedToSteam(done);
		}, 1000);
	}
	
	var beLoggedInToSteam = function(done) {
		if (loggedInToSteam) {
			return done();
		}
		
		setTimeout(function() {
			beLoggedInToSteam(done);
		}, 1000);
	};
	
	var beConnectedToDota2 = function(done) {
		if (connectedToDota2) {
			return done();
		}
		
		setTimeout(function() {
			beConnectedToDota2(done);
		}, 1000);
	};
	
	// Test functions
	var connectToSteam = function(done) {
		steamClient.connect();
		steamClient.on('connected', function() {
			connectedToSteam = true;
			done();
		});
	};
	
	var loginToSteam = function(done) {
		steamUser.logOn({
			"account_name": process.env.STEAM_USERNAME,
			"password": <PASSWORD>,
		});
		
		steamClient.on('logOnResponse', function onSteamLogOn(logonResp) {
			if (logonResp.eresult == steam.EResult.OK) {
				loggedInToSteam = true;
				done();
			} else {
				console.log(logonResp);
			}
		});
	};
 
	var connectToDota2 = function(done) {
		Dota2.launch();
		Dota2.on("ready", function() {
			connectedToDota2 = true;
			done();
		});
	};
	
	var convertSteamIDToAccountID = function() {
		var calculated_account_id = Dota2.ToAccountID(GABE_STEAM_ID);
		should(calculated_account_id.toString()).equal(GABE_ACCOUNT_ID);
	};
	
	var convertAccountIDToSteamID = function() {
		var calculated_steam_id = Dota2.ToSteamID(GABE_ACCOUNT_ID);
		should(calculated_steam_id.toString()).equal(GABE_STEAM_ID);
	};
	
	var invertKMsgTypeID = function() {
		var msg_type_id = "k_EMsgClientToGCGetProfileCard";
		var calculated_msg_type_id = dota2._getMessageName(dota2.schema.lookupEnum("EDOTAGCMsg").k_EMsgClientToGCGetProfileCard);
		should(calculated_msg_type_id).equal(msg_type_id);
	}
 
	// Tests
	describe('Steam', function() {
		this.timeout(20000); // 20s timeout because Steam is sooo slooooooooow
		
		describe('#connect', function() {
			it('should connect to Steam', connectToSteam);
		});
		
		describe('#login', function() {
			before(beConnectedToSteam);
			it('should login to Steam', loginToSteam);
		});
	});
	
	describe('Dota2', function() {
		this.timeout(20000); // 20s timeout because Steam is sooo slooooooooow
		
		// Check we're connected to Steam before running these tests
		before(beConnectedToSteam);
		before(beLoggedInToSteam);
		
		describe('Core', function () {
			describe('#launch', function () {
				it('should connect to Dota2 GC (recv \'ready\' event', connectToDota2);
			});
			
			describe('#exit', function () {
				// TODO: Not sure how we test this. Need to run it after all the other tests too.
				it('should disconnect from Dota2 GC');
			});
		});
		
		describe('Utilities', function () {
			describe('#ToTypeID', function () {
				it('should convert an enum to the corresponding message type ID ', invertKMsgTypeID);
			});
			
			describe('#ToAccountID', function () {
				it('should convert a 64-bit Steam ID into a 32-bit account ID', convertSteamIDToAccountID);
			});
			
			describe('#ToSteamID', function () {
				it('should convert a 32-bit account ID into a 64-bit Steam ID ', convertAccountIDToSteamID);
			});
		});
		
		describe('Inventory', function () {
			// TODO: No idea how we test these.
			describe('#setItemPositions', function () {
				it('should move the given items to the given positions');
			});
			
			describe('#deleteItem', function () {
				it('should delete the given item');
			});
		});
		
		describe('Chat', function () {
			describe('#joinChat', function () {
				it('should join a chat channel'); // TODO
			});
			
			describe('#leaveChat', function () {
				it('should leave a chat channel'); // TODO
			});
			
			describe('#sendMessage', function () {
				it('should a message to a chat channel'); // TODO
			});
			
			describe('#requestChatChannels', function () {<commit_msg>Added test for msg ID conversion<commit_after>var steam = require("steam"),
	dota2 = require("../"),
	steamClient = new steam.SteamClient(),
	steamUser = new steam.SteamUser(steamClient),
	Dota2 = new dota2.Dota2Client(steamClient, true, true),
	should = require('should');
	
	// Test data
	var GABE_STEAM_ID = '76561197960287930',
	GABE_ACCOUNT_ID = '22202';
    
	// App states, will be used to delay certain tests until conditions are met.
	var connectedToSteam = false,
		loggedInToSteam = false,
		connectedToDota2 = false;
	
	// Delays for certain states
	var beConnectedToSteam = function(done) {
		if (connectedToSteam) {
			return done();
		}
		
		setTimeout(function() {
			beConnectedToSteam(done);
		}, 1000);
	}
	
	var beLoggedInToSteam = function(done) {
		if (loggedInToSteam) {
			return done();
		}
		
		setTimeout(function() {
			beLoggedInToSteam(done);
		}, 1000);
	};
	
	var beConnectedToDota2 = function(done) {
		if (connectedToDota2) {
			return done();
		}
		
		setTimeout(function() {
			beConnectedToDota2(done);
		}, 1000);
	};
	
	// Test functions
	var connectToSteam = function(done) {
		steamClient.connect();
		steamClient.on('connected', function() {
			connectedToSteam = true;
			done();
		});
	};
	
	var loginToSteam = function(done) {
		steamUser.logOn({
			"account_name": process.env.STEAM_USERNAME,
			"password": process.env.STEAM_PASSWORD,
		});
		
		steamClient.on('logOnResponse', function onSteamLogOn(logonResp) {
			if (logonResp.eresult == steam.EResult.OK) {
				loggedInToSteam = true;
				done();
			} else {
				console.log(logonResp);
			}
		});
	};
 
	var connectToDota2 = function(done) {
		Dota2.launch();
		Dota2.on("ready", function() {
			connectedToDota2 = true;
			done();
		});
	};
	
	var convertSteamIDToAccountID = function() {
		var calculated_account_id = Dota2.ToAccountID(GABE_STEAM_ID);
		should(calculated_account_id.toString()).equal(GABE_ACCOUNT_ID);
	};
	
	var convertAccountIDToSteamID = function() {
		var calculated_steam_id = Dota2.ToSteamID(GABE_ACCOUNT_ID);
		should(calculated_steam_id.toString()).equal(GABE_STEAM_ID);
	};
	
	var invertKMsgTypeID = function() {
		var msg_type_id = "k_EMsgClientToGCGetProfileCard";
		var calculated_msg_type_id = dota2._getMessageName(dota2.schema.lookupEnum("EDOTAGCMsg").k_EMsgClientToGCGetProfileCard);
		should(calculated_msg_type_id).equal(msg_type_id);
	}
 
	// Tests
	describe('Steam', function() {
		this.timeout(20000); // 20s timeout because Steam is sooo slooooooooow
		
		describe('#connect', function() {
			it('should connect to Steam', connectToSteam);
		});
		
		describe('#login', function() {
			before(beConnectedToSteam);
			it('should login to Steam', loginToSteam);
		});
	});
	
	describe('Dota2', function() {
		this.timeout(20000); // 20s timeout because Steam is sooo slooooooooow
		
		// Check we're connected to Steam before running these tests
		before(beConnectedToSteam);
		before(beLoggedInToSteam);
		
		describe('Core', function () {
			describe('#launch', function () {
				it('should connect to Dota2 GC (recv \'ready\' event', connectToDota2);
			});
			
			describe('#exit', function () {
				// TODO: Not sure how we test this. Need to run it after all the other tests too.
				it('should disconnect from Dota2 GC');
			});
		});
		
		describe('Utilities', function () {
			describe('#ToTypeID', function () {
				it('should convert an enum to the corresponding message type ID ', invertKMsgTypeID);
			});
			
			describe('#ToAccountID', function () {
				it('should convert a 64-bit Steam ID into a 32-bit account ID', convertSteamIDToAccountID);
			});
			
			describe('#ToSteamID', function () {
				it('should convert a 32-bit account ID into a 64-bit Steam ID ', convertAccountIDToSteamID);
			});
			
			describe('#ToMsgID', function () {
				it('should convert a Msg ID to its name ', invertKMsgTypeID);
			});
		});
		
		describe('Inventory', function () {
			// TODO: No idea how we test these.
			describe('#setItemPositions', function () {
				it('should move the given items to the given positions');
			});
			
			describe('#deleteItem', function () {
				it('should delete the given item');
			});
		});
		
		describe('Chat', function () {
			describe('#joinChat', function () {
				it('should join a chat channel'); // TODO
			});
			
			describe('#leaveChat', function () {
				it('should leave a chat channel'); // TODO
			});
			
			describe('#sendMessage', function () {
				it('should a message to a chat channel'); // TODO
			});
			
			describe('#requestChatChannels', function () {
{'fraction_non_alphanumeric': 0.14019629712246265, 'fraction_numerical': 0.016952933303591346, 'mean_word_length': 3.7773042088439, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '859184', 'n_tokens_mistral': 3600, 'n_tokens_neox': 2930, 'n_words': 668}