Skip to content

Commit 21e7d9f

Browse files
feat: basic unit and snapshot tests
1 parent f728264 commit 21e7d9f

File tree

6 files changed

+520
-38
lines changed

6 files changed

+520
-38
lines changed

package-lock.json

Lines changed: 216 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@
4343
"Textual Protobuf",
4444
"pbtxt",
4545
"prototxt",
46-
"textproto"
46+
"textproto",
47+
"textpb",
48+
"txtpb"
4749
],
4850
"extensions": [
4951
".pbtxt",
5052
".prototxt",
51-
".textproto"
53+
".textproto",
54+
".textpb",
55+
".txtpb"
5256
],
5357
"configuration": "./language-configuration.json"
5458
}
@@ -84,13 +88,17 @@
8488
"format:check": "prettier --check .",
8589
"format:fix": "prettier --write .",
8690
"lint": "eslint .",
87-
"test": "npm run format:check && npm run lint",
91+
"test": "npm run format:check && npm run lint && npm run test:unit && npm run test:snapshot",
92+
"test:unit": "vscode-tmgrammar-test 'tests/unit/**/*.textproto'",
93+
"test:snapshot": "vscode-tmgrammar-snap 'tests/snap/**/*.textproto'",
94+
"test:snapshot:update": "vscode-tmgrammar-snap --updateSnapshot 'tests/snap/**/*.textproto'",
8895
"watch": "cross-env NODE_ENV=development npm run build -- --watch",
8996
"vscode:prepublish": "cross-env NODE_ENV=production npm run build"
9097
},
9198
"dependencies": {
9299
"highlight.js": "^10.4.1",
93-
"markdown-it-highlightjs": "^3.4.0"
100+
"markdown-it-highlightjs": "^3.4.0",
101+
"vscode-tmgrammar-test": "^0.1.3"
94102
},
95103
"devDependencies": {
96104
"@rollup/plugin-commonjs": "^17.0.0",

tests/snap/example.textproto

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This is a comment
2+
# hi there
3+
4+
b { c {
5+
d: 5
6+
}}
7+
8+
a {
9+
b: {
10+
c {
11+
d: 1043E-04f
12+
f: 0xfffFF00aeF
13+
reg_scalar: 10
14+
reg_scalar: -inf
15+
reg_message { foo: "bar" }
16+
[com.foo.ext.scalar]: 10
17+
[com.foo.ext.message] { foo: "bar" }
18+
19+
any_value {
20+
[type.googleapis.com/com.foo.any] { foo: "bar" }
21+
}
22+
nums: [
23+
1,
24+
2,
25+
3,
26+
4
27+
],
28+
objs: [
29+
{ a: 1 },
30+
{ a: 2 },
31+
{ a: 3 },
32+
{ a: 4 },
33+
],
34+
nums2: 3,
35+
nums2: 3,
36+
nums2: 3,
37+
nums2: 3,
38+
nums2: 3,
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)