all files / modules/utils/__tests__/ createProxy-test.js

100% Statements 15/15
100% Branches 0/0
100% Functions 4/4
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                          
const expect = require("expect");
const callApp = require("../callApp");
const createProxy = require("../createProxy");
 
describe("a proxy", function () {
    let proxy;
    beforeEach(function () {
        proxy = createProxy("http://www.example.com/the/path?the=query");
    });
 
    it("has the correct proxyLocation", function () {
    // This test may take a while because it makes a real network connection.
        this.timeout(3000);
 
        return callApp(proxy, "https://example.org:5000/more/path?more=query").then(function (conn) {
            const location = conn.proxyLocation;
 
            expect(location.protocol).toEqual("http:");
            expect(location.host).toEqual("www.example.com");
            expect(location.pathname).toEqual("/the/path/more/path");
            expect(location.query).toEqual({
                the: "query",
                more: "query"
            });
        });
    });
});