Demo entry 5233083

JJ

   

Submitted by anonymous on Jun 10, 2016 at 14:25
Language: JavaScript. Code size: 1.6 kB.

var
    server = require ('tests/tools/server')(3330),
    SUT = require ('./../bootstrap')('autotest').get('crawler')

describe ('Downloading entire website, each page once', function (){
    before (function(){
	server.returnHtml('/', ['page1.html', 'page2.html', 'page3.html'], ['/images/hello.jpg'])
        server.returnHtml('/page1.html', ['/'], ['/images/image1.jpg'])
        server.returnHtml('/page2.html', ['/'], ['/images/image1.jpg', '/images/image2.jpg'])
        server.returnHtml('/page3.html', ['/error404', 'timeout'], [])
        server.returnFile('/images/hello.jpg', './tests/files/hello.jpg')
        server.returnFile('/images/image1.jpg', './tests/files/image1.jpg')
        server.returnFile('/images/image2.jpg', './tests/files/image2.jpg')
        server.returnHttpError('/error404', 404)
        server.returnTimeout('/timeout')
        server.run()
    })
  
     beforeEach(function(){
        server.resetVisitCount()
        SUT.reset()
    })

    after(function(){
        server.stop()
    })

    it ('should visit all the urls on the server once', function(){
    	assert.ok (server.getVisitedPages().length = 8)
        assert.ok (server.getVisitCount('/') == 1)
        assert.ok (server.getVisitCount('/page1.html') == 1)
        assert.ok (server.getVisitCount('/page2.html') == 1)
        assert.ok (server.getVisitCount('/page3.html') == 1)
        assert.ok (server.getVisitCount('/images/hello.jpg') == 1)
        assert.ok (server.getVisitCount('/images/image1.jpg') == 1)
        assert.ok (server.getVisitCount('/images/image2.jpg') == 1)
    })
})

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).