{"size": 2276, "ext": "js", "max_stars_repo_path": "packages/browser-sync/test/specs/e2e/server/e2e.server.serveStatic.js", "max_stars_repo_name": "rotosix/browser-sync", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/browser-sync/test/specs/e2e/server/e2e.server.serveStatic.js", "max_issues_repo_name": "rotosix/browser-sync", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/browser-sync/test/specs/e2e/server/e2e.server.serveStatic.js", "max_forks_repo_name": "rotosix/browser-sync", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.3466666667, "max_line_length": 76, "alphanum_fraction": 0.3818101933}
var browserSync = require("../../../../");
var request = require("supertest");
var assert = require("chai").assert;

describe("E2E server test with serve static options", function () {
    it("sets the index of serve-static", function (done) {
        browserSync.reset();

        var config = {
            server: {
                baseDir: "test/fixtures",
                serveStaticOptions: {
                    index: "inputs.html",
                },
            },
            logLevel: "silent",
            open: false,
        };

        browserSync.create().init(config, function (err, bs) {
            assert.equal(
                bs.options.getIn(["server", "serveStaticOptions", "index"]),
                "inputs.html"
            );
            request(bs.server)
                .get("/")
                .expect(200)
                .end(function (err, res) {
                    assert.deepEqual(
                        require("fs").readFileSync(
                            "test/fixtures/inputs.html",
                            "utf-8"
                        ),
                        res.text
                    );
                    bs.cleanup();
                    done();
                });
        });
    });
    it("sets uses the default for serve static index", function (done) {
        browserSync.reset();

        var config = {
            server: {
                baseDir: "test/fixtures",
                serveStaticOptions: {},
            },
            logLevel: "silent",
            open: false,
        };

        browserSync.create().init(config, function (err, bs) {
            assert.equal(
                bs.options.getIn(["server", "serveStaticOptions", "index"]),
                "index.html"
            );
            request(bs.server)
                .get("/")
                .expect(200)
                .end(function (err, res) {
                    assert.deepEqual(
                        require("fs").readFileSync(
                            "test/fixtures/index.html",
                            "utf-8"
                        ),
                        res.text
                    );
                    bs.cleanup();
                    done();
                });
        });
    });
});
