Permalink
Browse files

NEW: Write skeleton of the test suite.

  • Loading branch information...
1 parent 4d7577b commit e125ae3783ef59961e8823122ace902ce1fae670 @lbdremy committed Feb 2, 2013
Showing with 106 additions and 17 deletions.
  1. +17 −0 test/html-redirection-test.js
  2. +17 −0 test/http-image-link-test.js
  3. +15 −17 test/scrapinode-test.js
  4. +57 −0 test/use-defaults-test.js
@@ -0,0 +1,17 @@
+/**
+ * Modules dependencies
+ */
+
+var mocha = require('mocha'),
+ assert = require('chai').assert,
+ libPath = process.env['SCRAPINODE_COV'] ? '../lib-cov' : '../lib',
+ scrapinode = require( libPath + '/scrapinode'),
+ ScrapinodeError = require(libPath + '/error/scrapinode-error');
+
+// Test suite
+
+describe('scrapinode#createScraper(url,callback)',function(){
+ describe('when a redirection is indicated in a HTML page',function(){
+ it('should follow the redirection');
+ });
+});
@@ -0,0 +1,17 @@
+/**
+ * Modules dependencies
+ */
+
+var mocha = require('mocha'),
+ assert = require('chai').assert,
+ libPath = process.env['SCRAPINODE_COV'] ? '../lib-cov' : '../lib',
+ scrapinode = require( libPath + '/scrapinode'),
+ ScrapinodeError = require(libPath + '/error/scrapinode-error');
+
+// Test suite
+
+describe('scrapinode#createScraper(url,callback)',function(){
+ describe('when a the url pointed to an image ressource',function(){
+ it('should create a HTML page and build the DOM based on this ressource and so be able to retrieve the url available in the attribute src of the tag img generated.');
+ });
+});
View
@@ -11,27 +11,25 @@ var mocha = require('mocha'),
// Test suite
describe('scrapinode',function(){
- describe('#use()',function(){
- it('should add the given path,content and operation as a new route',function(done){
- // Route that catchs everything
- scrapinode.use('*','*',function(window,next){
- return 'Goooogle it cannot find anything!';
- });
- scrapinode.createScraper('http://google.com',function(err,scraper){
- assert.isNull(err);
- assert.isObject(scraper);
- assert.equal(scraper.get('anything'),'Goooogle it cannot find anything!');
- done();
- });
- });
+ describe('#createScraper(url,callback)',function(){
+ it('should create a scraper for the page retrieved at the given url');
});
- describe('#useAll()',function(){
+ describe('#use({String} path, {String} content, {Function} operation)',function(){
+ it('should use the given path,content and operation as a new route');
+ });
+ describe('#use({RegExp} path, {RegExp} content, {Function} operation)',function(){
+ it('should use the given path,content and operation as a new route');
+ });
+ describe('#use("*", "*", {Function} operation)',function(){
+ it('should use the given path "*" ,content "*" and operation as a new route to catch all paths and contents asked');
+ });
+ describe('#useAll(routes)',function(){
it('should add all routes given');
});
- describe('#createScraper()',function(){
- it('should create a scraper for the page reached at the given url');
+ describe('#use() or #useAll()',function(){
+ it('should add the routes in the router ensuring the first route added is the first hit when browsering routes to retrieve a content if the path matchs obviously');
});
describe('#defaults()',function(){
- it('should return the routes to retrieve generic content from web pages like title,descriptions,images, videos');
+ it('should return the routes to retrieve generic content from web pages e.g title, descriptions, images and videos');
});
});
View
@@ -0,0 +1,57 @@
+/**
+ * Modules dependencies
+ */
+
+var mocha = require('mocha'),
+ assert = require('chai').assert,
+ libPath = process.env['SCRAPINODE_COV'] ? '../lib-cov' : '../lib',
+ scrapinode = require( libPath + '/scrapinode'),
+ ScrapinodeError = require(libPath + '/error/scrapinode-error');
+
+// Test suite
+
+['jsdom','cheerio'].forEach(runTestSuite);
+
+function runTestSuite(engine){
+ describe('scraper using the default operators thanks to ' + engine,function(){
+ describe('and scraping by following the Open Graph protocol',function(){
+ describe('#get("title")',function(){
+ it('should retrieve the text representating the title');
+ });
+ describe('#get("descriptions")',function(){
+ it('should retrieve a list of text representating the descriptions');
+ });
+ describe('#get("images")',function(){
+ it('should retrieve a list of images url');
+ });
+ describe('#get("videos")',function(){
+ it('should retrieve a list of videos [urls or html representations of the videos]');
+ });
+ });
+ describe('and scraping by following the Schema.org specifications',function(){
+ describe('#get("title")',function(){
+ it('should retrieve the text representating the title');
+ });
+ describe('#get("descriptions")',function(){
+ it('should retrieve a list of text representating the descriptions');
+ });
+ describe('#get("images")',function(){
+ it('should retrieve a list of images url');
+ });
+ });
+ describe('and scraping by searching the generic html tags',function(){
+ describe('#get("title")',function(){
+ it('should retrieve the text representating the title');
+ });
+ describe('#get("descriptions")',function(){
+ it('should retrieve a list of text representating the descriptions');
+ });
+ describe('#get("images")',function(){
+ it('should retrieve a list of images url');
+ });
+ describe('#get("videos")',function(){
+ it('should retrieve a list of videos [urls or html representations of the videos]');
+ });
+ });
+ });
+}

0 comments on commit e125ae3

Please sign in to comment.