Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var retrieveUnemployment = function(callback) {
// Screen scrape BLS web page for latest unemployment information
zombie.visit("http://data.bls.gov/timeseries/LNS14000000", function(err,
browser, status) {
var unemploymentData = [];
// Grab the unemployment table
var ths = browser.querySelectorAll("table.regular-data tbody th");
for ( var i = 0; i < ths.length; i++) {
var unemploymentEntry = {};
// Grab each row header and use it to set the year
var th = ths.item(i);
var year = th.innerHTML.trim();
// Grab each cell in the row and use it to set the month and
// unemployment rate
var tds = th.parentNode.getElementsByTagName("td");
for ( var j = 0; j < tds.length && j < 12; j++) {
var retrieveEarnings = function(callback) {
// Screen scrape BLS web page for latest unemployment information
zombie.visit("http://data.bls.gov/cgi-bin/srgate", function(err,
browser, status) {
var earningsData = [];
// Fill in a text area with the name "series_id" with the series for
// weekly earnings, press the submit button, then press the "Retrieve Data"
// button on the resulting page
browser.
fill("series_id", "LES1252881600").
pressButton(".submit-button", function(err, browser, status) {
browser.pressButton("Retrieve Data", function(err, browser, status) {
// Define the processing function for earnings data
var ths = browser.querySelectorAll("table.regular-data tbody th");
for ( var i = 0; i < ths.length; i++) {
var earningsEntry = {};
var th = ths.item(i);
function getHTMLSnapshot(url, noCache, cb) {
if(!cb){
cb = noCache;
noCache = false;
}
if(!noCache){
var cached = cache.get(url);
if(cached) return cb(null, cached);
}
Browser.visit(url, {waitFor: options.waitFor},
function(err, browser, status) {
if(err) return cb(err);
// links
var links = browser.queryAll('a');
links.forEach(function(link) {
var href = link.getAttribute('href');
if(href !== null) {
var absoluteUrl = urlParser.resolve(url, href);
link.setAttribute('href', absoluteUrl);
}
});
var snapshot = stripScripts(browser.html());
cache.set(url, snapshot);
cb(null, snapshot);
var retrieveConsumerPriceIndex8284 = function(callback) {
// Screen scrape BLS web page for latest cpi information
zombie.visit("http://data.bls.gov/timeseries/CUUR0000SA0", function(err,
browser, status) {
var cpiData = [];
// Grab the cpi table
var ths = browser.querySelectorAll("table.regular-data tbody th");
for ( var i = 0; i < ths.length; i++) {
var cpiEntry = {};
// Grab each row header and use it to set the year
var th = ths.item(i);
var year = th.innerHTML.trim();
// Grab each cell in the row and use it to set the month and
// cpi index
var tds = th.parentNode.getElementsByTagName("td");
for ( var j = 0; j < tds.length && j < 12; j++) {
module.exports['compile\t"'+name+'"'] = function(assert) {
currentTestCode = code
if (isFirstTest) { console.log('loading headless browser...'); isFirstTest = false }
zombie.visit('http://localhost:'+compilerServerPort, function(err, browser, status) {
if (err) { throw err }
if (status != 200) { throw new Error("Got bad status from compiler server:", status) }
var nextAction = function() {
if (!actions.length) {
assert.done()
scheduleCompilerServerShutdown()
return
}
var action = actions.shift()
try {
actionHandlers[action.name].apply(this, [assert, browser, nextAction].concat(action.args))
} catch(e) {
console.log('compiler threw:', e.stack, '\nThe code that caused the throw:\n', currentTestCode)
}
}
nextAction()
app.listen('5000', function() {
console.log('Test server listening on 5000');
Browser.visit('http://localhost:5000', function(err, b) {
browser = b;
$ = browser.window.$;
ajaxSpy = sinon.spy($, 'ajax');
browser.wait(function(){
browser.window.$(function(){
done();
});
});
});
});
});
it('passes all tests', function(done){
zombie.visit('http://localhost:5000/', function(err, browser, status){
var lastDuration = 0;
function checkResults(browser){
var passes = parseInt(browser.text('#mocha #stats .passes em'), 10),
failures = parseInt(browser.text('#mocha #stats .failures em') || '0', 10);
expect(passes).toBeGreaterThan(-1);
expect(failures).toEqual(0);
done();
}
function checkTestStatus(){
browser.wait(function(){
var duration = parseFloat(browser.text('#mocha #stats .duration em'), 10);
if(duration === lastDuration){
test("Checking badges", function (done) {
Browser.visit(home, function (e, browser) {
expect(browser.query("#badges .badge:nth-child(1) p:contains('Top Committer')")).to.be.ok();
expect(browser.query("#badges .badge:nth-child(2) p:contains('Fatty Committer')")).to.be.ok();
expect(browser.query("#badges .badge:nth-child(1) img[src='/badges/topCommiter.png']")).to.be.ok();
expect(browser.query("#badges .badge:nth-child(2) img[src='/badges/fatty.png']")).to.be.ok();
done();
});
});
beforeEach( function() {
zombie.visit( "http://localhost:1337/", function( error, _browser, status ) {
if( error ) throw error;
expect( status ).toBe( 200 );
browser = _browser;
asyncSpecDone();
});
asyncSpecWait();
});