2017-08-15 17:28:23 +00:00
|
|
|
import { expect, tap } from 'tapbundle'
|
|
|
|
import * as smarttime from '../ts/index'
|
|
|
|
|
2017-08-16 12:29:12 +00:00
|
|
|
|
|
|
|
// Test TimeStamp class
|
|
|
|
let testTimeStamp: smarttime.TimeStamp
|
|
|
|
let testTimeStamp2: smarttime.TimeStamp
|
|
|
|
tap.test('should create valid testTimeStamp instance', async (tools) => {
|
|
|
|
testTimeStamp = new smarttime.TimeStamp()
|
|
|
|
await tools.delayFor(2)
|
|
|
|
testTimeStamp2 = new smarttime.TimeStamp()
|
|
|
|
expect(testTimeStamp).to.be.instanceof(smarttime.TimeStamp)
|
|
|
|
expect(testTimeStamp).to.be.instanceof(smarttime.TimeStamp)
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('should have valid linuxtime', async () => {
|
|
|
|
// tslint:disable-next-line:no-unused-expression
|
|
|
|
expect(testTimeStamp.isOlderThan(testTimeStamp2)).to.be.true
|
2017-08-16 12:39:25 +00:00
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2017-08-16 12:29:12 +00:00
|
|
|
expect(testTimeStamp.isYoungerThan(testTimeStamp2)).to.be.false
|
2017-08-15 17:28:23 +00:00
|
|
|
})
|
|
|
|
|
2017-08-16 12:29:12 +00:00
|
|
|
let testHrtMeasurement: smarttime.HrtMeasurement
|
|
|
|
|
|
|
|
// Test HrtMeasurement
|
|
|
|
tap.test('should create valid HrtMeasurements', async (tools) => {
|
|
|
|
testHrtMeasurement = new smarttime.HrtMeasurement()
|
|
|
|
testHrtMeasurement.start()
|
|
|
|
await tools.delayFor(20)
|
|
|
|
testHrtMeasurement.stop()
|
|
|
|
expect(testHrtMeasurement.milliSeconds).to.be.greaterThan(19)
|
|
|
|
expect(testHrtMeasurement.milliSeconds).to.be.lessThan(25)
|
|
|
|
})
|
|
|
|
|
2017-08-16 14:24:56 +00:00
|
|
|
// check units
|
|
|
|
tap.test('should combine units', async () => {
|
|
|
|
let computedTime = smarttime.getMilliSecondsFromUnits({
|
|
|
|
years: 2,
|
|
|
|
months: 2,
|
|
|
|
weeks: 2,
|
|
|
|
days: 2,
|
|
|
|
hours: 2,
|
|
|
|
minutes: 2
|
|
|
|
})
|
|
|
|
console.log(computedTime)
|
|
|
|
})
|
2017-08-16 12:29:12 +00:00
|
|
|
|
2017-08-15 17:28:23 +00:00
|
|
|
tap.start()
|