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

use named export for timeTree, use null as initialization value for TimeTreeNode.stop #221

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
AVV_ERR_ROOT_PLG_BOOTED,
AVV_ERR_READY_TIMEOUT
} = require('./lib/errors')
const TimeTree = require('./lib/time-tree')
const { TimeTree } = require('./lib/time-tree')
const Plugin = require('./plugin')
const { debug } = require('./lib/debug')
const kAvvio = Symbol('kAvvio')
Expand Down
8 changes: 5 additions & 3 deletions lib/time-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TimeTree {
label,
nodes: [],
start,
stop: undefined,
stop: null,
diff: -1
}
this[kTrackNode](this.root)
Expand All @@ -116,7 +116,7 @@ class TimeTree {
label,
nodes: [],
start,
stop: undefined,
stop: null,
diff: -1
}
parentNode.nodes.push(childNode)
Expand Down Expand Up @@ -186,4 +186,6 @@ function prettyPrintTimeTree (obj, prefix = '') {
return result
}

module.exports = TimeTree
module.exports = {
TimeTree
}
14 changes: 7 additions & 7 deletions test/lib/time-tree.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { test } = require('tap')
const TimeTree = require('../../lib/time-tree')
const { TimeTree } = require('../../lib/time-tree')

test('TimeTree is constructed with a root attribute, set to null', t => {
t.plan(1)
Expand Down Expand Up @@ -60,7 +60,7 @@ test('TimeTree#start is adding a node with correct shape, root-node', t => {
t.ok('start' in rootNode)
t.ok(Number.isInteger(rootNode.start))
t.ok('stop' in rootNode)
t.type(rootNode.stop, 'undefined')
t.type(rootNode.stop, 'null')
t.ok('diff' in rootNode)
t.type(rootNode.diff, 'number')
})
Expand Down Expand Up @@ -90,7 +90,7 @@ test('TimeTree#start is adding a node with correct shape, child-node', t => {
t.ok('start' in childNode)
t.ok(Number.isInteger(childNode.start))
t.ok('stop' in childNode)
t.type(childNode.stop, 'undefined')
t.type(childNode.stop, 'null')
t.ok('diff' in childNode)
t.type(childNode.diff, 'number')
})
Expand Down Expand Up @@ -226,7 +226,7 @@ test('TimeTree#stop sets stop value of node', t => {

const tree = new TimeTree()
tree.start(null, 'root')
t.type(tree.root.stop, 'undefined')
t.type(tree.root.stop, 'null')

tree.stop('root')
t.type(tree.root.stop, 'number')
Expand All @@ -238,7 +238,7 @@ test('TimeTree#stop parameter stop is used as stop value of node', t => {

const tree = new TimeTree()
tree.start(null, 'root')
t.type(tree.root.stop, 'undefined')
t.type(tree.root.stop, 'null')

tree.stop('root', 1337)
t.type(tree.root.stop, 'number')
Expand All @@ -263,10 +263,10 @@ test('TimeTree#stop does nothing when node is not found', t => {

const tree = new TimeTree()
tree.start(null, 'root')
t.type(tree.root.stop, 'undefined')
t.type(tree.root.stop, 'null')

tree.stop('invalid')
t.type(tree.root.stop, 'undefined')
t.type(tree.root.stop, 'null')
})

test('TimeTree untracks node ids /1', t => {
Expand Down