{"size": 1492, "ext": "js", "max_stars_repo_path": "test/testpageevaluate.js", "max_stars_repo_name": "fru-old/advanced-phantom", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/testpageevaluate.js", "max_issues_repo_name": "fru-old/advanced-phantom", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/testpageevaluate.js", "max_forks_repo_name": "fru-old/advanced-phantom", "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": 36.3902439024, "max_line_length": 92, "alphanum_fraction": 0.4698391421}
var http = require('http');
var phantom = require('../src/index.js');
var server;

module.exports = {
    setUp: function (cb) {
        server = http.createServer(function (request, response) {
            response.writeHead(200,{"Content-Type": "text/html"});
            response.end('<html><head></head><body><h1>Hello World</h1></body></html>');
        }).listen(cb);
    },
    tearDown: function (cb) {
        server.close(cb);
    },
    testPhantomPageEvaluate: function (test) {
        phantom.create(function (error, ph) {
            test.ifError(error);
            ph.createPage(function (err,page) {
                test.ifError(err);
                page.open('http://localhost:'+server.address().port, function (err,status) {
                    test.ifError(err);
                    test.equal(status,'success');
                    page.evaluate(function () {
                        return { h1text: document.getElementsByTagName('h1')[0].innerText };
                    }, function (err, result) {
                        test.ifError(err);
                        test.equal(result.h1text,'Hello World');
                        ph.on('exit', function () {
                            test.done();
                        });
                        ph.exit();
                    });
                });
            });
        }, {
          ignoreErrorPattern: /CoreText performance note/, 
          phantomPath: require('phantomjs').path
        });
    },
};
