Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tests #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.12"
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# containerized-node-testing-tutorial
A repository for a containerized node testing tutorial

[![Build Status](https://travis-ci.org/benbakhar/containerized-node-testing-tutorial.svg?branch=feat%2Ftests)](https://travis-ci.org/benbakhar/containerized-node-testing-tutorial)

DockUnit
11 changes: 10 additions & 1 deletion test/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ describe('time', function() {

});

});
describe('#getPretty', function() {

it('should return string representation of the time', function() {
var time = new Time();

assert(typeof time.getPretty() === 'string2');
})
})

});
32 changes: 15 additions & 17 deletions time.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
'use strict';

class Time {
constructor() {
this.date = new Date();
function Time() {
this.date = new Date();

this.hour = this.date.getHours();
this.hour = (this.hour < 10 ? '0' : '') + this.hour;
this.hour = this.date.getHours();
this.hour = (this.hour < 10 ? '0' : '') + this.hour;

this.min = this.date.getMinutes();
this.min = (this.min < 10 ? '0' : '') + this.min;
this.min = this.date.getMinutes();
this.min = (this.min < 10 ? '0' : '') + this.min;

this.ampm = 'AM';
if (this.hour > 12) {
this.ampm = 'PM';
this.hour -= 12;
}
}

getPretty() {
return 'The time is ' + this.hour + ':' + this.min + ' ' + this.ampm;
this.ampm = 'AM';
if (this.hour > 12) {
this.ampm = 'PM';
this.hour -= 12;
}
}

module.exports = Time;
Time.prototype.getPretty = function() {
return 'The time is ' + this.hour + ':' + this.min + ' ' + this.ampm;
};

module.exports = Time;