<commit_before>var http = require("http"),
    assert = require("assert"),
    request = require("request"),
    routilCookie = require("../index"),
    getCookie = routilCookie.getCookie,
    setCookie = routilCookie.setCookie,
    Jar = request.jar()

var handlers =  {
    "/get": function (req, res) {
        res.end(getCookie(req, "name"))
    },
    "/set": function (req, res) {
        setCookie(res, "name", "value")
        res.end()
    },
    "/null": function (req, res) {
        res.end(getCookie(req, "notExist") === null ? "null" : "fail")
    },
    "/multiple": function (req, res) {
        setCookie(res, {
            "foo": "bar",
            "foo2": "bar2"
        })
        res.end()
    }
}

describe("Integration tests", function () {
    var server

    before(function (done) {
        server = http.createServer(function (req, res) {
            handlers[req.url](req, res)
        }).listen(3000, function () { done() })
    })

    it("should set a cookie", function (done) {
        makeRequest("/set", function (err, res, body) {
            assert.equal(res.headers["set-cookie"],<commit_msg>support 0.4 in unit tests<commit_after>var http = require("http"),
    assert = require("assert"),
    request = require("request"),
    routilCookie = require("../index"),
    getCookie = routilCookie.getCookie,
    setCookie = routilCookie.setCookie,
    Jar = request.jar()

var handlers =  {
    "/get": function (req, res) {
        res.end(getCookie(req, "name"))
    },
    "/set": function (req, res) {
        setCookie(res, "name", "value")
        res.end()
    },
    "/null": function (req, res) {
        res.end(getCookie(req, "notExist") === null ? "null" : "fail")
    },
    "/multiple": function (req, res) {
        setCookie(res, {
            "foo": "bar",
            "foo2": "bar2"
        })
        res.end()
    }
}

describe("Integration tests", function () {
    var server

    before(function (done) {
        server = http.createServer(function (req, res) {
            handlers[req.url](req, res)
        })
        server.listen(3000, function () { done() })
    })

    it("should set a cookie", function (done) {
        makeRequest("/set", function (err, res, body) {
            assert.equal(res.headers["set-cookie"],
{'fraction_non_alphanumeric': 0.1763676148796499, 'fraction_numerical': 0.00612691466083151, 'mean_word_length': 2.3178519593613935, 'pattern_counts': {'":': 12, '<': 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': '1506479', 'n_tokens_mistral': 726, 'n_tokens_neox': 712, 'n_words': 159}