Skip to content

Commit 2db4305

Browse files
committed
Other: Added lib/path tests and updated a few dependencies
1 parent 2b12fb7 commit 2db4305

File tree

5 files changed

+78
-8
lines changed

5 files changed

+78
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,16 @@ Additionally, TypeScript definitions of static modules are compatible with refle
346346
1. Instead of using `new SomeMessage(...)`, always use `SomeMessage.create(...)` because reflection objects do not provide a constructor.
347347
2. Types, services and enums must start with an uppercase letter to become available as properties of the reflected types as well (i.e. to be able to use `MyMessage.MyEnum` instead of `root.lookup("MyMessage.MyEnum")`).
348348

349-
For example, the following generates a `bundle.json` and a `bundle.d.ts`, but no static code:
349+
For example, the following generates a JSON module `bundle.js` and a `bundle.d.ts`, but no static code:
350350

351351
```
352-
$> pbjs -t json-module -w commonjs -o bundle.json file1.proto file2.proto
352+
$> pbjs -t json-module -w commonjs -o bundle.js file1.proto file2.proto
353353
$> pbjs -t static-module file1.proto file2.proto | pbts -o bundle.d.ts -
354354
```
355355

356356
### On reflection vs. static code
357357

358-
While using .proto files requires the [full library][dist-full] (about 18.5kb gzipped) or JSON at least the [light library][dist-light] (about 15.5kb gzipped), pretty much all code but the relatively short descriptors is shared and all features including reflection and the parser are available.
358+
While using .proto files directly requires the [full library][dist-full] (about 18.5kb gzipped) respectively pure reflection/JSON the [light library][dist-light] (about 15.5kb gzipped), pretty much all code but the relatively short descriptors is shared.
359359

360360
Static code, on the other hand, requires just the [minimal library][dist-minimal] (about 6kb gzipped), but generates additional, albeit editable, source code without any reflection features.
361361

lib/path/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
{
22
"name": "@protobufjs/path",
33
"description": "A minimal path module to resolve Unix, Windows and URL paths alike.",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/dcodeIO/protobuf.js.git"
99
},
1010
"license": "BSD-3-Clause",
1111
"main": "index.js",
12-
"types": "index.d.ts"
12+
"types": "index.d.ts",
13+
"devDependencies": {
14+
"istanbul": "^0.4.5",
15+
"tape": "^4.6.3"
16+
},
17+
"scripts": {
18+
"test": "tape tests/*.js",
19+
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
20+
}
1321
}

lib/path/tests/index.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var tape = require("tape");
2+
3+
var path = require("..");
4+
5+
tape.test("path", function(test) {
6+
7+
test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");
8+
test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");
9+
10+
test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");
11+
test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");
12+
13+
var paths = [
14+
{
15+
actual: "X:\\some\\..\\.\\path\\\\file.js",
16+
normal: "X:/path/file.js",
17+
resolve: {
18+
origin: "X:/path/origin.js",
19+
expected: "X:/path/file.js"
20+
}
21+
}, {
22+
actual: "some\\..\\.\\path\\\\file.js",
23+
normal: "path/file.js",
24+
resolve: {
25+
origin: "X:/path/origin.js",
26+
expected: "X:/path/path/file.js"
27+
}
28+
}, {
29+
actual: "/some/.././path//file.js",
30+
normal: "/path/file.js",
31+
resolve: {
32+
origin: "/path/origin.js",
33+
expected: "/path/file.js"
34+
}
35+
}, {
36+
actual: "some/.././path//file.js",
37+
normal: "path/file.js",
38+
resolve: {
39+
origin: "",
40+
expected: "path/file.js"
41+
}
42+
}, {
43+
actual: ".././path//file.js",
44+
normal: "../path/file.js"
45+
}, {
46+
actual: "/.././path//file.js",
47+
normal: "/path/file.js"
48+
}
49+
];
50+
51+
paths.forEach(function(p) {
52+
test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);
53+
if (p.resolve) {
54+
test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);
55+
test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");
56+
}
57+
});
58+
59+
test.end();
60+
});

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
"@types/long": "^3.0.31"
6161
},
6262
"devDependencies": {
63-
"@types/node": "7.0.3",
63+
"@types/node": "7.0.4",
6464
"benchmark": "^2.1.3",
65-
"browserify": "^13.3.0",
65+
"browserify": "^14.0.0",
6666
"browserify-wrap": "^1.0.2",
6767
"bundle-collapser": "^1.2.1",
6868
"chalk": "^1.1.3",
@@ -79,7 +79,8 @@
7979
"gulp-header": "^1.8.8",
8080
"gulp-if": "^2.0.1",
8181
"gulp-sourcemaps": "^2.4.0",
82-
"gulp-uglify": "^2.0.0",
82+
"gulp-uglify": "^2.0.1",
83+
"istanbul": "^0.4.5",
8384
"jaguarjs-jsdoc": "dcodeIO/jaguarjs-jsdoc",
8485
"jsdoc": "^3.4.2",
8586
"minimist": "^1.2.0",

tests/lib_path.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("../lib/path/tests");

0 commit comments

Comments
 (0)