D.O.H. test for document.domain

115 views Asked by At

I am trying to write a D.O.H. test for a function which determines if the current environment is running in either production or a local development machine. The function accomplishes this by analyzing the string in the document.domain property. Is there a way to programmatically set the document.domain property so that when the function is called from the D.O.H. test, the domain I specify will get analyzed? Here is the function:

isProdEnvironment = function() {
        var nonProdRegExp = new RegExp( 'localhost|dev|test|perf' );
        var isNonProd = nonProdRegExp.test( document.domain );
        return ! isNonProd;
    };

In my test case, I wanted to do something like:

document.domain = 'someProdEnvironment.com';
doh.assertFalse (isProdEnvironment());

However, everytime I do this, the test always passes due to the fact the document.domain call in the isProdEnvironment() function keeps retrieving the domain of the development machine that my tests are running on (i.e. 'localhost').

0

There are 0 answers