add first mocha test

This commit is contained in:
Mike Barrett 2014-07-17 23:13:01 +01:00
parent 09089fa812
commit 60b303f7cb
5 changed files with 28 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
test
node_modules

View File

@ -1,2 +1,6 @@
test
node_modules
.editorconfig
.jshintrc
Gruntfile.js
.DS_Store
dist

View File

@ -11,7 +11,7 @@ module.exports = function(grunt) {
uglify: {
dist: {
files: {
'dist/<%= pkg.name %>.min.js': 'src/<%= pkg.name %>.js'
'dist/<%= pkg.name %>.min.js': '<%= pkg.name %>.js'
}
}
},
@ -21,7 +21,7 @@ module.exports = function(grunt) {
},
files: [
'Gruntfile.js',
'src/**/*.js',
'<%= pkg.name %>.js',
'test/**/*.js'
]
},

21
test/timestring.js Normal file
View File

@ -0,0 +1,21 @@
var chai = require('chai');
var expect = chai.expect;
var timestring = require('../timestring');
describe('timestring', function() {
it('should expose a method on String.prototype that will attempt to parse the string as a timestring', function(done){
var str = '1min';
// no arguments passed
expect(str.parseTime()).to.equal(60);
// units argument passed
expect(str.parseTime('m')).to.equal(1);
// units + settings argument passed
str = '5h';
expect(str.parseTime('d', { hoursPerDay: 5 })).to.equal(1);
done();
});
});