Skip to content

Commit

Permalink
updated test code
Browse files Browse the repository at this point in the history
  • Loading branch information
bchr02 committed Aug 17, 2015
1 parent ef22571 commit 0cc718d
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
"use strict";

var expect = require("chai").expect;
var should = require("chai").should();
var Epochjs = require("../index");

describe("Track the amount of time that has elapsed", function() {
describe("seconds", function() {
it("is a positive number", function() {
describe("Epochjs", function() {
describe(".start()", function() {
it("should be called on init", function() {
var epochjs = new Epochjs();
epochjs.start();
expect(epochjs.seconds).to.be.above(0);
should.exist(epochjs.seconds);
});
it("returns a number", function() {
var epochjs = new Epochjs();
});
describe(".seconds", function() {
it("should be the number of seconds since midnight of January 1, 1970", function() {
var epochjs = new Epochjs(),
d = new Date(),
r = d.getTime() / 1000;
epochjs.start();
expect(epochjs.seconds).to.be.a('number');
epochjs.seconds.should.be.within(r,r+10);
});
});
describe("secElapsed()", function() {
it("returns a number", function() {
describe(".secElapsed()", function() {
it("should return a postive number indicating the number of seconds that have ellapsed since start() was last called.", function() {
var epochjs = new Epochjs();
epochjs.start();
expect(epochjs.secElapsed()).to.be.a('number');
epochjs.secElapsed().should.be.within(0,10);
});
it("is a positive number", function() {
var epochjs = new Epochjs();
});
describe(".log()", function() {
it("should log a message to the console", function() {
var oldconsole = console,
console = {
log: function(s) {
if (s == message) {
return true;
}
}},
message = 'test',
result = false,
epochjs = new Epochjs(),
check;
epochjs.start();
expect(epochjs.secElapsed()).to.be.at.least(0);
});
it("returns a number even when not explicitly calling start()", function() {
var epochjs = new Epochjs();
expect(epochjs.secElapsed()).to.be.a('number');
check = epochjs.log(message);
console = oldconsole;
should.exist(check);
check.should.be.true();
});
});
});

0 comments on commit 0cc718d

Please sign in to comment.