Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
csbun committed Jul 21, 2015
1 parent 44bed41 commit 0e1ac9e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"bitwise": true,
"camelcase": true,
"eqeqeq": true,
"esnext": true,
"forin": true,
"immed": true,
"indent": 4,
"latedef": false,
"newcap": true,
"noarg": true,
"noempty": true,
"predef": ["describe", "it"],
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"eqnull": true,
"browser": true,
"devel": true,
"node": true,
"white": false
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Simple datetime formater

[![NPM](https://nodei.co/npm/silly-datetime.png?compact=true)](https://nodei.co/npm/silly-datetime/)

[![Build Status](https://travis-ci.org/csbun/silly-datetime.svg)](https://travis-ci.org/csbun/silly-datetime)
[![Coverage Status](https://coveralls.io/repos/csbun/silly-datetime/badge.svg?branch=master&service=github)](https://coveralls.io/github/csbun/silly-datetime?branch=master)

## Install

```
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "silly-datetime",
"version": "0.0.1",
"version": "0.0.2",
"description": "simple datetime formater",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"repository": {
"type": "git",
Expand All @@ -19,5 +19,11 @@
"bugs": {
"url": "https://github.com/csbun/silly-datetime/issues"
},
"homepage": "https://github.com/csbun/silly-datetime"
"homepage": "https://github.com/csbun/silly-datetime",
"devDependencies": {
"coveralls": "^2.11.3",
"istanbul": "^0.3.17",
"mocha": "^2.2.5",
"mocha-lcov-reporter": "0.0.2"
}
}
20 changes: 20 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var assert = require('assert');
var sd = require('../index');

var FORMAT_A = 'YYYY-MM-DD HH:mm:ss';
var FORMAT_B = 'M/D/YYYY H:m a';

describe('silly-datetime', function () {
describe('#format', function () {
var datetime = new Date(2015, 7, 6, 15, 10, 3);
console.log(datetime);
it('should return as `' + FORMAT_A + '`', function () {
assert.equal('2015-08-06 15:10:03', sd.format(datetime, FORMAT_A));
});
it('should return as `' + FORMAT_B + '`', function () {
assert.equal('8/6/2015 15:10 pm', sd.format(datetime, FORMAT_B));
});
});
});

0 comments on commit 0e1ac9e

Please sign in to comment.