replaces unit testing framework ava -> uvu
This commit is contained in:
parent
c3d7d64a51
commit
1c135a0c1f
|
|
@ -2,47 +2,50 @@
|
|||
/*
|
||||
Open Rowing Monitor, https://github.com/laberning/openrowingmonitor
|
||||
*/
|
||||
import test from 'ava'
|
||||
import { test } from 'uvu'
|
||||
import * as assert from 'uvu/assert'
|
||||
import BufferBuilder from './BufferBuilder.js'
|
||||
import log from 'loglevel'
|
||||
log.setLevel(log.levels.SILENT)
|
||||
|
||||
test('valid max UInts should produce correct buffer', t => {
|
||||
test('valid max UInts should produce correct buffer', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt8(255)
|
||||
buffer.writeUInt16LE(65535)
|
||||
buffer.writeUInt24LE(16777215)
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]))
|
||||
})
|
||||
|
||||
test('valid min UInts should produce correct buffer', t => {
|
||||
test('valid min UInts should produce correct buffer', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt8(0)
|
||||
buffer.writeUInt16LE(0)
|
||||
buffer.writeUInt24LE(0)
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0x0, 0x0, 0x0, 0x0, 0x0, 0x0]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0x0, 0x0, 0x0, 0x0, 0x0, 0x0]))
|
||||
})
|
||||
|
||||
test('negative UInt8 should produce 1 bit buffer of 0x0', t => {
|
||||
test('negative UInt8 should produce 1 bit buffer of 0x0', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt8(-1)
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0x0]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0x0]))
|
||||
})
|
||||
|
||||
test('negative UInt16LE should produce 2 bit buffer of 0x0', t => {
|
||||
test('negative UInt16LE should produce 2 bit buffer of 0x0', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt16LE(-1)
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0x0, 0x0]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0x0, 0x0]))
|
||||
})
|
||||
|
||||
test('negative writeUInt24LE should produce 3 bit buffer of 0x0', t => {
|
||||
test('negative writeUInt24LE should produce 3 bit buffer of 0x0', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt24LE(-1)
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0x0, 0x0, 0x0]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0x0, 0x0, 0x0]))
|
||||
})
|
||||
|
||||
test('invalid datatype value UInt16LE should produce 2 bit buffer of 0x0', t => {
|
||||
test('invalid datatype value UInt16LE should produce 2 bit buffer of 0x0', () => {
|
||||
const buffer = new BufferBuilder()
|
||||
buffer.writeUInt16LE(new Map())
|
||||
t.deepEqual(buffer.getBuffer(), Buffer.from([0x0, 0x0]))
|
||||
assert.equal(buffer.getBuffer(), Buffer.from([0x0, 0x0]))
|
||||
})
|
||||
|
||||
test.run()
|
||||
|
|
|
|||
|
|
@ -2,37 +2,39 @@
|
|||
/*
|
||||
Open Rowing Monitor, https://github.com/laberning/openrowingmonitor
|
||||
*/
|
||||
import test from 'ava'
|
||||
import { test } from 'uvu'
|
||||
import * as assert from 'uvu/assert'
|
||||
|
||||
import { createMovingIntervalAverager } from './MovingIntervalAverager.js'
|
||||
|
||||
test('average of a datapoint with duration of averager is equal to datapoint', t => {
|
||||
test('average of a datapoint with duration of averager is equal to datapoint', () => {
|
||||
const minuteAverager = createMovingIntervalAverager(10)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
t.is(minuteAverager.average(), 5)
|
||||
assert.is(minuteAverager.average(), 5)
|
||||
})
|
||||
|
||||
test('average of a datapoint with half duration of averager is double to datapoint', t => {
|
||||
test('average of a datapoint with half duration of averager is double to datapoint', () => {
|
||||
const minuteAverager = createMovingIntervalAverager(20)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
t.is(minuteAverager.average(), 10)
|
||||
assert.is(minuteAverager.average(), 10)
|
||||
})
|
||||
|
||||
test('average of two identical datapoints with half duration of averager is equal to datapoint sum', t => {
|
||||
test('average of two identical datapoints with half duration of averager is equal to datapoint sum', () => {
|
||||
const minuteAverager = createMovingIntervalAverager(20)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
t.is(minuteAverager.average(), 10)
|
||||
assert.is(minuteAverager.average(), 10)
|
||||
})
|
||||
|
||||
test('average does not consider datapoints that are outside of duration', t => {
|
||||
test('average does not consider datapoints that are outside of duration', () => {
|
||||
const minuteAverager = createMovingIntervalAverager(20)
|
||||
minuteAverager.pushValue(10, 10)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
minuteAverager.pushValue(5, 10)
|
||||
t.is(minuteAverager.average(), 10)
|
||||
assert.is(minuteAverager.average(), 10)
|
||||
})
|
||||
|
||||
test('average works with lots of values', t => {
|
||||
test('average works with lots of values', () => {
|
||||
// one hour
|
||||
const minuteAverager = createMovingIntervalAverager(3000)
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
|
|
@ -44,5 +46,7 @@ test('average works with lots of values', t => {
|
|||
for (let i = 0; i < 1000; i++) {
|
||||
minuteAverager.pushValue(30, 2)
|
||||
}
|
||||
t.is(minuteAverager.average(), 50000)
|
||||
assert.is(minuteAverager.average(), 50000)
|
||||
})
|
||||
|
||||
test.run()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -20,7 +20,8 @@
|
|||
"dev": "npm-run-all --parallel start build:watch",
|
||||
"build": "snowpack build",
|
||||
"build:watch": "snowpack build --watch",
|
||||
"test": "ava"
|
||||
"test": "uvu",
|
||||
"test:watch": "uvu --watch"
|
||||
},
|
||||
"ava": {
|
||||
"verbose": true
|
||||
|
|
@ -36,7 +37,6 @@
|
|||
"ws": "^7.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
|
@ -46,6 +46,8 @@
|
|||
"husky": "^5.1.3",
|
||||
"markdownlint-cli": "^0.27.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"snowpack": "^3.1.2"
|
||||
"snowpack": "^3.1.2",
|
||||
"uvu": "^0.5.1",
|
||||
"uvu-watch": "^1.0.11"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue