Skip to content

Commit 1dd8c4d

Browse files
author
Daniel Wirtz
committed
Migrated tests to test.js
1 parent 5fdb07e commit 1dd8c4d

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
},
1414
"keywords": ["net", "array", "buffer", "arraybuffer", "typed array", "bytebuffer", "json", "websocket", "webrtc"],
1515
"dependencies": {
16-
"long": ">=1.1.2"
16+
"long": "latest"
1717
},
1818
"devDependencies": {
19-
"nodeunit": ">=0.7",
20-
"preprocessor": ">=1.0.2",
21-
"closurecompiler": ">=1.1"
19+
"testjs": "latest",
20+
"preprocessor": "latest",
21+
"closurecompiler": "latest"
2222
},
2323
"license": "Apache License, Version 2.0",
2424
"engines": {
2525
"node": ">=0.8"
2626
},
2727
"scripts": {
2828
"prepublish": "npm test",
29-
"test": "nodeunit tests/suite.js",
29+
"test": "node node_modules/testjs/bin/testjs tests/suite.js",
3030

3131
"make": "npm run-script build && npm run-script compile && npm run-script noexpose && npm test && npm run-script jsdoc",
3232
"build": "preprocess src/ByteBuffer.js src/ > ByteBuffer.js",

tests/suite.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ var Sandbox = function(properties) {
6060
* @type {Object.<string,function>}
6161
*/
6262
var suite = {
63-
64-
setUp: function (callback) {
65-
callback();
66-
},
67-
68-
tearDown: function (callback) {
69-
callback();
70-
},
7163

7264
"init": function(test) {
7365
test.ok(typeof ByteBuffer == "function");
@@ -346,15 +338,15 @@ var suite = {
346338
var bb = new ByteBuffer(4);
347339
bb.writeUint32(0x12345678);
348340
bb.flip();
349-
test.equals(0x12345678, bb.readUint32());
341+
test.equal(0x12345678, bb.readUint32());
350342
test.done();
351343
},
352344

353345
"write/readFloat32": function(test) {
354346
var bb = new ByteBuffer(4);
355347
bb.writeFloat32(0.5);
356348
bb.flip();
357-
test.equals(0.5, bb.readFloat32()); // 0.5 remains 0.5 if Float32
349+
test.equal(0.5, bb.readFloat32()); // 0.5 remains 0.5 if Float32
358350
test.done();
359351
},
360352

@@ -369,7 +361,7 @@ var suite = {
369361
var bb = new ByteBuffer(8);
370362
bb.writeFloat64(0.1);
371363
bb.flip();
372-
test.equals(0.1, bb.readFloat64()); // would be 0.10000000149011612 if Float32
364+
test.equal(0.1, bb.readFloat64()); // would be 0.10000000149011612 if Float32
373365
test.done();
374366
},
375367

@@ -597,7 +589,7 @@ var suite = {
597589
bb.writeLString("ab"); // resizes to 4
598590
test.equal(bb.array.byteLength, 4);
599591
test.equal(bb.offset, 3);
600-
test.equals(bb.length, 0);
592+
test.equal(bb.length, 0);
601593
bb.flip();
602594
test.equal(bb.toHex(), "<02 61 62>00 ");
603595
test.deepEqual({"string": "ab", "length": 3}, bb.readLString(0));
@@ -612,7 +604,7 @@ var suite = {
612604
bb.writeVString("ab"); // resizes to 4
613605
test.equal(bb.array.byteLength, 4);
614606
test.equal(bb.offset, 3);
615-
test.equals(bb.length, 0);
607+
test.equal(bb.length, 0);
616608
bb.flip();
617609
test.equal(bb.toHex(), "<02 61 62>00 ");
618610
test.deepEqual({"string": "ab", "length": 3}, bb.readVString(0));
@@ -707,9 +699,9 @@ var suite = {
707699
for (var i=0; i<chars.length;i++) {
708700
ByteBuffer.encodeUTF8Char(chars[i], bb, 0);
709701
dec = ByteBuffer.decodeUTF8Char(bb, 0);
710-
test.equals(chars[i], dec['char']);
711-
test.equals(ByteBuffer.calculateUTF8Char(chars[i]), dec["length"]);
712-
test.equals(String.fromCharCode(chars[i]), String.fromCharCode(dec['char']));
702+
test.equal(chars[i], dec['char']);
703+
test.equal(ByteBuffer.calculateUTF8Char(chars[i]), dec["length"]);
704+
test.equal(String.fromCharCode(chars[i]), String.fromCharCode(dec['char']));
713705
}
714706
test.throws(function() {
715707
ByteBuffer.encodeUTF8Char(-1, bb, 0);
@@ -726,7 +718,7 @@ var suite = {
726718
test.done();
727719
},
728720

729-
"protobuf.js issue 19": function(test) {
721+
"pbjsi19": function(test) {
730722
// test that this issue is fixed: https://github.com/dcodeIO/ProtoBuf.js/issues/19
731723
var bb = new ByteBuffer(9); // Trigger resize to 18 in writeVarint64
732724
bb.writeVarint32(16);
@@ -737,7 +729,7 @@ var suite = {
737729
bb.writeVarint64(ByteBuffer.Long.fromString("1368057600000"));
738730
bb.writeVarint32(40);
739731
bb.writeVarint64(ByteBuffer.Long.fromString("1235455123"));
740-
test.equals(bb.toHex(18), ">10 02 18 00 20 80 B0 D9 B4 E8 27 28 93 99 8E CD 04<00 ");
732+
test.equal(bb.toHex(18), ">10 02 18 00 20 80 B0 D9 B4 E8 27 28 93 99 8E CD 04<00 ");
741733
test.done();
742734
},
743735

0 commit comments

Comments
 (0)