Skip to content

Commit a85c5ba

Browse files
committed
Move tests to js and test in Node 6, 8, 9
1 parent b057cd8 commit a85c5ba

17 files changed

+270
-529
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

lib/DomainName.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A single level of a domain name
32

43
const debug = require('debug')('d::domain-tree::DomainName')
@@ -32,4 +31,4 @@ module.exports = class DomainName extends TreeNode {
3231
return o
3332
}
3433

35-
}
34+
}

lib/DomainNameSystem.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A single level of a domain name
32

43
const debug = require('debug')('d::domain-tree::DomainNameSystem')
@@ -20,4 +19,4 @@ module.exports = class DomainNameSystem {
2019
this._host = host
2120
}
2221

23-
}
22+
}

lib/DomainNames.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A group of Domain Name
32

43
const debug = require('debug')('d::domain-tree::DomainNames')
@@ -36,4 +35,4 @@ module.exports = class DomainNames extends Tree {
3635

3736
}
3837

39-
module.exports.node_type = DomainName
38+
module.exports.node_type = DomainName

lib/Tree.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A Tree to hold TreeNodes
32

43
// If you extend this to hold another type of node, ovrride

lib/TreeData.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A single tree nodes data
32

43
const debug = require('debug')('d::domain-tree::TreeData')
@@ -32,4 +31,4 @@ module.exports = class TreeData {
3231
return this.parent.data[key][item] = value
3332
}
3433

35-
}
34+
}

lib/TreeNode.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// A single tree node
32
// Root node has null parent
43

@@ -77,5 +76,4 @@ module.exports = class TreeNode {
7776
return str
7877
}
7978

80-
}
81-
79+
}

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const DomainName = require('./DomainName')
77
const DomainNames = require('./DomainNames')
88

99
debug('main export')
10-
module.exports = { TreeNode, Tree, DomainName, DomainNames, VERSION }
10+
module.exports = { TreeNode, Tree, DomainName, DomainNames, VERSION }

make.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
3+
set -ue
4+
5+
rundir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
6+
canonical="$rundir/$(basename -- "$0")"
7+
8+
if [ -n "${1:-}" ]; then
9+
cmd=$1
10+
shift
11+
else
12+
cmd=build
13+
fi
14+
15+
cd "$rundir"
16+
17+
###
18+
19+
SCOPE="dply"
20+
NAME="node-domain-tree-test"
21+
IMAGE="$SCOPE/$NAME"
22+
23+
build_test_docker(){
24+
#build_test_docker_version 4
25+
build_test_docker_version 6 "-q"
26+
build_test_docker_version 8 "-q" # lts
27+
build_test_docker_version 9 "-q" # latest
28+
docker tag $IMAGE:9 $IMAGE:latest
29+
docker tag $IMAGE:8 $IMAGE:lts
30+
}
31+
build_test_docker_version(){
32+
build_test_docker_version=${1:-latest}
33+
build_test_docker_version_args=${2:-}
34+
docker build \
35+
$build_test_docker_version_args \
36+
--build-arg NODE_VERSION=$build_test_docker_version \
37+
-t $IMAGE:$build_test_docker_version \
38+
-f test/fixture/Dockerfile \
39+
.
40+
}
41+
42+
run_test(){
43+
docker run $IMAGE:lts
44+
}
45+
run_test_all(){
46+
build_test_docker
47+
#docker run $IMAGE:4
48+
docker run $IMAGE:6
49+
docker run $IMAGE:8
50+
docker run $IMAGE:9
51+
}
52+
53+
###
54+
55+
run_help(){
56+
echo "Commands:"
57+
awk '/ ".*"/{ print " "substr($1,2,length($1)-3) }' make.sh
58+
}
59+
set +x
60+
case $cmd in
61+
"build") build_test_docker "$@";;
62+
"build:test") build_test_docker "$@";;
63+
"build:test:docker") build_test_docker "$@";;
64+
"test") run_test "$@";;
65+
"test:all") run_test_all "$@";;
66+
"test:lts") run_test_lts "$@";;
67+
"test:latest") run_test_latest "$@";;
68+
"watch") run_watch "$@";;
69+
70+
'-h'|'--help'|'h'|'help') run_help;;
71+
*) $cmd "$@";;
72+
esac
73+

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
"license": "MIT",
2828
"devDependencies": {
2929
"benchmark": "^2.1.2",
30-
"chai": "^3.5.0",
31-
"microtime": "^2.1.1",
32-
"mocha": "^3.1.2"
30+
"chai": "^4.1.2",
31+
"mocha": "^5.0.2"
3332
},
3433
"dependencies": {
35-
"coffeescript": "^2.2.2",
36-
"debug": "^2.0.0"
34+
"debug": "^3.1.0"
3735
},
3836
"engine": "node >= 6.0"
3937
}

0 commit comments

Comments
 (0)