Skip to content

Commit 7d0abf0

Browse files
committed
Re-write / re-factor test suite
1 parent 6f4b44f commit 7d0abf0

14 files changed

+194
-281
lines changed

makefile

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
build:
22
node ./build/index.js
33

4-
generator:
5-
npm install
6-
git init
7-
git add -A
8-
git remote add origin https://[email protected]/thisandagain/sentiment
4+
test:
5+
./node_modules/.bin/tap test/governance/*.js
6+
./node_modules/.bin/tap test/unit/*.js
97

10-
.PHONY: build generator
8+
benchmark:
9+
node test/benchmark/index.js
10+
11+
.PHONY: build test benchmark

test/benchmark.js renamed to test/benchmark/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Test suite
2+
* Naïve benchmark suite.
33
*
44
* @package sentiment
55
* @author Andrew Sliwinski <[email protected]>
@@ -11,7 +11,7 @@
1111
var async = require('async'),
1212
test = require('tap').test,
1313

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

1717
/**

test/debt.js

-39
This file was deleted.

test/governance/lint.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var fs = require('fs'),
2+
hint = require('hint-hint');
3+
4+
var config = fs.readFileSync(__dirname + '/../../.jshintrc');
5+
hint(__dirname + '/../../lib/*.js', JSON.parse(config));

test/index.js

-129
This file was deleted.

test/inject.js

-105
This file was deleted.

test/unit/default_comments.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var async = require('async'),
2+
test = require('tap').test,
3+
sentiment = require(__dirname + '/../../lib/index');
4+
5+
var load = [
6+
'In America I doubt it could sustain itself without descending into identity politics and ego.',
7+
'You are deluding yourself if you think that identity politics and ego are purely American.',
8+
'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.',
9+
'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.',
10+
'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.',
11+
'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.'
12+
];
13+
14+
async.map(load, function (obj, callback) {
15+
sentiment(obj, callback);
16+
}, function (err, obj) {
17+
console.dir(err);
18+
console.dir(obj);
19+
20+
test('unit', function (t) {
21+
t.equal(err, null, 'error object should be null');
22+
t.type(obj, 'object', 'results should be an object');
23+
t.equal(obj.length, 6, 'results should be of expected length');
24+
25+
t.equal(obj[0].score, -1, 'Expected score');
26+
t.equal(obj[0].comparative, -0.06666666666666667, 'Expected comparative score');
27+
t.equal(obj[0].tokens.length, 15, 'Expected tokens length');
28+
t.equal(obj[0].words.length, 1, 'Expected match length');
29+
30+
t.end();
31+
});
32+
});

0 commit comments

Comments
 (0)