Skip to content

Commit

Permalink
Re-write / re-factor test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
thisandagain committed Jul 30, 2013
1 parent 6f4b44f commit 7d0abf0
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 281 deletions.
13 changes: 7 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
build:
node ./build/index.js

generator:
npm install
git init
git add -A
git remote add origin https://thisandagain@github.com/thisandagain/sentiment
test:
./node_modules/.bin/tap test/governance/*.js
./node_modules/.bin/tap test/unit/*.js

.PHONY: build generator
benchmark:
node test/benchmark/index.js

.PHONY: build test benchmark
4 changes: 2 additions & 2 deletions test/benchmark.js → test/benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test suite
* Naïve benchmark suite.
*
* @package sentiment
* @author Andrew Sliwinski <andrew@diy.org>
Expand All @@ -11,7 +11,7 @@
var async = require('async'),
test = require('tap').test,

t1 = require(__dirname + '/../lib/index.js'),
t1 = require(__dirname + '/../../lib/index.js'),
t2 = require('Sentimental');

/**
Expand Down
39 changes: 0 additions & 39 deletions test/debt.js

This file was deleted.

5 changes: 5 additions & 0 deletions test/governance/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fs = require('fs'),
hint = require('hint-hint');

var config = fs.readFileSync(__dirname + '/../../.jshintrc');
hint(__dirname + '/../../lib/*.js', JSON.parse(config));
129 changes: 0 additions & 129 deletions test/index.js

This file was deleted.

105 changes: 0 additions & 105 deletions test/inject.js

This file was deleted.

32 changes: 32 additions & 0 deletions test/unit/default_comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var async = require('async'),
test = require('tap').test,
sentiment = require(__dirname + '/../../lib/index');

var load = [
'In America I doubt it could sustain itself without descending into identity politics and ego.',
'You are deluding yourself if you think that identity politics and ego are purely American.',
'Posting a show that cost $5 and was for charity is pretty low and I thought better of BoingBoing. A clip or two would be great, but just pirating something like this is lame.',
'I paid the $5, only got to see the last 30 minutes of the event, and cant download it today, because when I log in, it asks for my credit card information. So the only way it looks like Ill get to watch it is through a pirated copy.',
'Thanks for posting it, Cory! What Ive seen of the debate was awesome, but from a technical and customer service standpoint, it was a catastrophe.',
'Bill OReillys total inability to shut up while anyone else is speaking makes me either wonder how he ever got his job, or think that you can be inordinately successful just by bullying.'
];

async.map(load, function (obj, callback) {
sentiment(obj, callback);
}, function (err, obj) {
console.dir(err);
console.dir(obj);

test('unit', function (t) {
t.equal(err, null, 'error object should be null');
t.type(obj, 'object', 'results should be an object');
t.equal(obj.length, 6, 'results should be of expected length');

t.equal(obj[0].score, -1, 'Expected score');
t.equal(obj[0].comparative, -0.06666666666666667, 'Expected comparative score');
t.equal(obj[0].tokens.length, 15, 'Expected tokens length');
t.equal(obj[0].words.length, 1, 'Expected match length');

t.end();
});
});
Loading

0 comments on commit 7d0abf0

Please sign in to comment.