<commit_before>'use strict';
/* global describe, it, before, beforeEach, afterEach, after */

const fs = require("fs");

const assert = require("chai").assert;
const logging = require("winston");
const nock = require("nock");
const sinon = require("sinon");
const supertest = require("supertest");

const cache = require("./cache.js");
const fetchPackage = require("./fetch_package.js");
const graphiteUtil = require("./graphite_util.js");
const renderSecret = require("./secret.js");
const renderWorkers = require("./render_workers.js");
const server = require("./server.js");

describe('API endpoint /_api/ping', () => {
    const agent = supertest.agent(server);

    it("should return pong", (done) => {
        agent
            .get('/_api/ping')
            .expect("pong!\n", done);
    });
});

describe('API endpoint /_api/version', () => {
    const agent = supertest.agent(server);
    afterEach(function() {
        delete process.env['GAE_VERSION'];
    });

    it("should return the module version in production", (done) => {
        process.env['GAE_VERSION'] = 'foo-version';
        agent
            .get('/_api/version')
            .expect("foo-version\n", done);
    });

    it("should return the 'dev' in dev", (done) => {
        agent
            .get('/_api/version')
            .expect("dev\n", done);
    });
});

describe('API endpoint /_ah/health', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/health')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /_ah/start', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/start')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /_ah/stop', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/stop')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /render', function() {
    this.timeout(4000);

    const agent = supertest.agent(server);

    let mockScope;<commit_msg>Add some comments around the new timeout.<commit_after>'use strict';
/* global describe, it, before, beforeEach, afterEach, after */

const fs = require("fs");

const assert = require("chai").assert;
const logging = require("winston");
const nock = require("nock");
const sinon = require("sinon");
const supertest = require("supertest");

const cache = require("./cache.js");
const fetchPackage = require("./fetch_package.js");
const graphiteUtil = require("./graphite_util.js");
const renderSecret = require("./secret.js");
const renderWorkers = require("./render_workers.js");
const server = require("./server.js");

describe('API endpoint /_api/ping', () => {
    const agent = supertest.agent(server);

    it("should return pong", (done) => {
        agent
            .get('/_api/ping')
            .expect("pong!\n", done);
    });
});

describe('API endpoint /_api/version', () => {
    const agent = supertest.agent(server);
    afterEach(function() {
        delete process.env['GAE_VERSION'];
    });

    it("should return the module version in production", (done) => {
        process.env['GAE_VERSION'] = 'foo-version';
        agent
            .get('/_api/version')
            .expect("foo-version\n", done);
    });

    it("should return the 'dev' in dev", (done) => {
        agent
            .get('/_api/version')
            .expect("dev\n", done);
    });
});

describe('API endpoint /_ah/health', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/health')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /_ah/start', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/start')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /_ah/stop', () => {
    const agent = supertest.agent(server);

    it("should return ok!", (done) => {
        agent
            .get('/_ah/stop')
            .expect("ok!\n", done);
    });
});

describe('API endpoint /render', function() {
    // Jenkins can be a slow machine, and each of these tests has to
    // start up a subprocess to actually do the rendering, which can
    // be a slow operation.  So double the timeout from the 2s default.
    this.timeout(4000);

    const agent = supertest.agent(server);

    let mockScope;
{'fraction_non_alphanumeric': 0.1843956043956044, 'fraction_numerical': 0.001978021978021978, 'mean_word_length': 2.6349840255591053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2052402', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1349, 'n_words': 331}