alexarank

A simple node package to get Alexa traffic rank for a domain or URL
Log | Files | Refs | README | LICENSE

commit 8e2c0b3d5fbec93f78d39642f3c7fa9cec1c45e3
parent 116895aa0f4f669df553b8f5f1d45fcf099143e9
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Mon, 27 Jan 2014 00:11:18 +0100

Adding tests

Diffstat:
Mpackage.json | 7+++++++
Atest/test.js | 20++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/package.json b/package.json @@ -6,6 +6,9 @@ "bin": { "alexarank": "./bin/alexarank" }, + "scripts": { + "test": "mocha" + }, "repository": { "type": "git", "url": "https://github.com/fcambus/alexarank.git" @@ -30,5 +33,9 @@ "dependencies": { "xml2js": "~0.4.0", "request": "~2.30.0" + }, + "devDependencies": { + "mocha": "~1.17.1", + "should": "~3.1.0" } } diff --git a/test/test.js b/test/test.js @@ -0,0 +1,20 @@ +var alexa = require('../lib/alexarank'); +var should = require('should'); + +describe('alexarank', function() { + it('Should return an object with correct elements types', function(done) { + alexa("http://www.echojs.com", function(error, result) { + should.not.exist(error); + + result.should.be.an.Object; + + result.url.should.equal('echojs.com/'); + result.idn.should.equal('echojs.com/'); + + parseInt(result.rank).should.be.a.Number; + parseInt(result.reach).should.be.a.Number; + + done(); + }); + }); +});