Skip to content

Commit 7cd8fc0

Browse files
committed
npm run test:format
1 parent d4015be commit 7cd8fc0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

format/test/resolver.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {files, fromFile} from "../lib/input";
2+
import {formatMessage} from "../lib/tools";
3+
import {validate} from "../lib/validate";
4+
import {Resource} from "../resolver/resource";
5+
6+
const specs = process.argv[2];
7+
8+
if (!specs) {
9+
console.error("Usage: node resolver.js SPEC");
10+
process.exit(1);
11+
}
12+
13+
for (let file of files(specs, ".md")) {
14+
let source = fromFile(file);
15+
validate(format, file, source);
16+
}
17+
18+
function format(input: string) {
19+
let resource = new Resource(input);
20+
let result = formatMessage(resource, new Map(), "test");
21+
return JSON.stringify(result, null, 4);
22+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"test:ebnf": "node -r esm ./syntax/test/ebnf.js ./syntax/parser/grammar.js ./syntax/spec/fluent.ebnf",
2020
"test:fixtures": "node -r esm ./syntax/test/parser.js ./syntax/test/fixtures",
2121
"test:unit": "node -r esm ./syntax/test/literals.js",
22-
"test": "npm run --silent test:fixtures && npm run --silent test:unit",
22+
"test:format": "node ./build/format/test/resolver.js ./format/spec/",
23+
"test": "npm run --silent test:fixtures && npm run --silent test:unit && npm run --silent test:format",
2324
"watch": "tsc --watch"
2425
},
2526
"homepage": "https://projectfluent.org",

0 commit comments

Comments
 (0)