Skip to content

Commit 2d1a608

Browse files
committed
Switch to nodeUnit
1 parent 5930d79 commit 2d1a608

File tree

4 files changed

+70
-41
lines changed

4 files changed

+70
-41
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
node_modules
1+
node_modules
2+
_SpecRunner.html
3+
.grunt

Gruntfile.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,15 @@ module.exports = function(grunt) {
1212
all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
1313
},
1414

15-
// Jamsine
16-
jasmine: {
17-
emailBuilder: {
18-
src: 'index.js',
19-
options: {
20-
specs: 'test/specs/*Spec.js',
21-
helpers: 'test/spec/*Helper.js'
22-
}
23-
}
15+
// Unit tests
16+
nodeunit: {
17+
tests: ['test/*_test.js']
2418
}
2519
});
2620

2721
// Load tasks
2822
grunt.loadNpmTasks('grunt-contrib-jshint');
29-
grunt.loadNpmTasks('grunt-contrib-jasmine');
23+
grunt.loadNpmTasks('grunt-contrib-nodeunit');
3024

3125
// Default task(s).
3226
grunt.registerTask('default', ['jshint']);

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"grunt": "^0.4.5",
2626
"grunt-contrib-jasmine": "^0.8.1",
2727
"grunt-contrib-jshint": "^0.10.0",
28+
"grunt-contrib-nodeunit": "^0.4.1",
2829
"jshint-stylish": "^1.0.0"
2930
}
3031
}

test/specs/EmailBuilderSpec.js

+62-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,62 @@
1-
describe("Calendar Stuff", function() {
2-
var emailBuilder;
3-
4-
beforeEach(function() {
5-
emailBuilder = new EmailBuilder();
6-
});
7-
8-
describe('Something something', function() {
9-
var today;
10-
11-
beforeEach(function() {
12-
today = new Date();
13-
});
14-
15-
it('should be main entry', function() {
16-
var expected = '<strong>10:00</strong> AM';
17-
var unit = 'hours';
18-
var minutesFrom = 60;
19-
20-
today.setHours(10, 0, 0, 0);
21-
var dateString = calendar.constructTimeEntry(today, minutesFrom, unit);
22-
23-
expect(dateString.date).toBe('<strong>10:00</strong> AM');
24-
});
25-
26-
27-
});
28-
29-
30-
});
1+
'use strict';
2+
3+
var EmailBuilder = require('./');
4+
5+
/*
6+
======== A Handy Little Nodeunit Reference ========
7+
https://github.com/caolan/nodeunit
8+
9+
Test methods:
10+
test.expect(numAssertions)
11+
test.done()
12+
Test assertions:
13+
test.ok(value, [message])
14+
test.equal(actual, expected, [message])
15+
test.notEqual(actual, expected, [message])
16+
test.deepEqual(actual, expected, [message])
17+
test.notDeepEqual(actual, expected, [message])
18+
test.strictEqual(actual, expected, [message])
19+
test.notStrictEqual(actual, expected, [message])
20+
test.throws(block, [error], [message])
21+
test.doesNotThrow(block, [error], [message])
22+
test.ifError(value)
23+
*/
24+
25+
exports.init_gruntplugin_sample = {
26+
setUp: function(done) {
27+
// setup here if necessary
28+
29+
var emailBuilder = new EmailBuilder();
30+
31+
done();
32+
},
33+
default_options: function(test) {
34+
35+
var actual;
36+
var expected;
37+
38+
test.expect(5);
39+
40+
actual = grunt.file.read('reports/test-report');
41+
expected = grunt.file.read('test/expected/test-report');
42+
test.equal(actual, expected, 'Should produce a default report without DOM element for a test file');
43+
44+
actual = grunt.file.read('reports/test-report-dom');
45+
expected = grunt.file.read('test/expected/test-report-dom');
46+
test.equal(actual, expected, 'Should produce a default report with DOM element for a test file');
47+
48+
actual = grunt.file.read('reports/test-report.json');
49+
expected = grunt.file.read('test/expected/test-report.json');
50+
test.equal(actual, expected, 'Should produce JSON report without DOM element for a test file');
51+
52+
actual = grunt.file.read('reports/test-report-dom.json');
53+
expected = grunt.file.read('test/expected/test-report-dom.json');
54+
test.equal(actual, expected, 'Should produce JSON report with DOM element for a test file');
55+
56+
actual = grunt.file.read('reports/test-report-ignore.txt');
57+
expected = grunt.file.read('test/expected/test-report-ignore.txt');
58+
test.equal(actual, expected, 'Should ignore certain rules');
59+
60+
test.done();
61+
}
62+
};

0 commit comments

Comments
 (0)