<commit_before>// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
(function() {
	"use strict";

	var server = require("./server.js");
	var http = require("http");
	var fs = require("fs");
	var assert = require("assert");

	var CONTENT_DIR = "generated/test";

	var HOME_PAGE = "index.html";
	var NOT_FOUND_PAGE = "test404.html";

	var HOME_PAGE_DATA = "This is home page file";
	var NOT_FOUND_DATA = "This is 404 page file";

	var PORT = 5020;
	var BASE_URL = "http://localhost:" + PORT;

	exports.setUp = function(done) {
		fs.writeFileSync(CONTENT_DIR + "/" + HOME_PAGE, HOME_PAGE_DATA);
		fs.writeFileSync(CONTENT_DIR + "/" + NOT_FOUND_PAGE, NOT_FOUND_DATA);

		done();
	};

	exports.tearDown = function(done) {
		cleanUpFile(CONTENT_DIR + "/" + HOME_PAGE);
		cleanUpFile(CONTENT_DIR + "/" + NOT_FOUND_PAGE);
		done();
	};

	exports.test_servesFilesFromDirectory = function(test) {
		httpGet(BASE_URL + "/index.html", function(response, responseData) {
			test.equals(200, response.statusCode, "status code");
			test.equals(HOME_PAGE_DATA, responseData, "response text");
			test.done();
		});
	};

	exports.test_supportsMultipleFiles = function(test) {
		//TODO
		test.done();
	};

	exports.test_servesIndexDotHtmlWhenAskedForHomePage = function(test) {
		httpGet(BASE_URL, function(response, responseData) {
			test.equals(200, response.statusCode, "status code");
			test.equals(HOME_PAGE_DATA, responseData, "response text");
			test.done();
		});
	};

	exports.test_returns404WhenFileDoesNotExist = function(test) {
		httpGet(BASE_URL + "/bargle", function(response, responseData) {
			test.equals(404, response.statusCode, "status code");
			test.equals(NOT_FOUND_DATA, responseData, "404 text");
			test.done();
		});
	};

	exports.test_requiresHomePageParameter = function(test) {
		test.throws(function() {
			server.start();
		});
		test.done();<commit_msg>Added test for multi-page support<commit_after>// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
(function() {
	"use strict";

	var server = require("./server.js");
	var http = require("http");
	var fs = require("fs");
	var assert = require("assert");

	var CONTENT_DIR = "generated/test";

	var INDEX_PAGE = "index.html";
	var OTHER_PAGE = "other.html";
	var NOT_FOUND_PAGE = "test404.html";

	var INDEX_PAGE_DATA = "This is index page file";
	var OTHER_PAGE_DATA = "This is another page";
	var NOT_FOUND_DATA = "This is 404 page file";

	var PORT = 5020;
	var BASE_URL = "http://localhost:" + PORT;

	exports.setUp = function(done) {
		fs.writeFileSync(CONTENT_DIR + "/" + INDEX_PAGE, INDEX_PAGE_DATA);
		fs.writeFileSync(CONTENT_DIR + "/" + OTHER_PAGE, OTHER_PAGE_DATA);
		fs.writeFileSync(CONTENT_DIR + "/" + NOT_FOUND_PAGE, NOT_FOUND_DATA);

		done();
	};

	exports.tearDown = function(done) {
		cleanUpFile(CONTENT_DIR + "/" + INDEX_PAGE);
		cleanUpFile(CONTENT_DIR + "/" + OTHER_PAGE);
		cleanUpFile(CONTENT_DIR + "/" + NOT_FOUND_PAGE);
		done();
	};

	exports.test_servesFilesFromDirectory = function(test) {
		httpGet(BASE_URL + "/" + INDEX_PAGE, function(response, responseData) {
			test.equals(200, response.statusCode, "status code");
			test.equals(INDEX_PAGE_DATA, responseData, "response text");
			test.done();
		});
	};

	exports.test_supportsMultipleFiles = function(test) {
		httpGet(BASE_URL + "/" + OTHER_PAGE, function(response, responseData) {
			test.equals(200, response.statusCode, "status code");
			test.equals(OTHER_PAGE_DATA, responseData, "response text");
			test.done();
		});
	};

	exports.test_servesIndexDotHtmlWhenAskedForHomePage = function(test) {
		httpGet(BASE_URL, function(response, responseData) {
			test.equals(200, response.statusCode, "status code");
			test.equals(INDEX_PAGE_DATA, responseData, "response text");
			test.done();
		});
	};

	exports.test_returns404WhenFileDoesNotExist = function(test) {
		httpGet(BASE_URL + "/bargle", function(response, responseData) {
			test.equals(404, response.statusCode, "status code");
			test.equals(NOT_FOUND_DATA, responseData, "404 text");
			test.done();
		});
	};

	exports.test_requiresHomePageParameter = function(test) {
		test.throws(function() {
			server.start();
		});
		test.done();
{'fraction_non_alphanumeric': 0.15067201131808536, 'fraction_numerical': 0.014383400141476066, 'mean_word_length': 4.779291553133515, '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': '5079489', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1443, 'n_words': 284}