From 60b303f7cb2cff62dec4009e8a3b3b11d5abca2c Mon Sep 17 00:00:00 2001 From: Mike Barrett Date: Thu, 17 Jul 2014 23:13:01 +0100 Subject: [PATCH] add first mocha test --- .gitignore | 1 - .npmignore | 6 +++++- Gruntfile.js | 4 ++-- test/timestring.js | 21 +++++++++++++++++++++ src/timestring.js => timestring.js | 0 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 test/timestring.js rename src/timestring.js => timestring.js (100%) diff --git a/.gitignore b/.gitignore index d3e222c..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -test node_modules diff --git a/.npmignore b/.npmignore index d3e222c..d481e52 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,6 @@ test -node_modules +.editorconfig +.jshintrc +Gruntfile.js +.DS_Store +dist diff --git a/Gruntfile.js b/Gruntfile.js index 2fa8098..44c694a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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' ] }, diff --git a/test/timestring.js b/test/timestring.js new file mode 100644 index 0000000..8a54209 --- /dev/null +++ b/test/timestring.js @@ -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(); + }); +}); diff --git a/src/timestring.js b/timestring.js similarity index 100% rename from src/timestring.js rename to timestring.js