Skip to content

Commit

Permalink
npm run test:format
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Jul 31, 2019
1 parent d4015be commit 7cd8fc0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions format/test/resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {files, fromFile} from "../lib/input";
import {formatMessage} from "../lib/tools";
import {validate} from "../lib/validate";
import {Resource} from "../resolver/resource";

const specs = process.argv[2];

if (!specs) {
console.error("Usage: node resolver.js SPEC");
process.exit(1);
}

for (let file of files(specs, ".md")) {
let source = fromFile(file);
validate(format, file, source);
}

function format(input: string) {
let resource = new Resource(input);
let result = formatMessage(resource, new Map(), "test");
return JSON.stringify(result, null, 4);
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"test:ebnf": "node -r esm ./syntax/test/ebnf.js ./syntax/parser/grammar.js ./syntax/spec/fluent.ebnf",
"test:fixtures": "node -r esm ./syntax/test/parser.js ./syntax/test/fixtures",
"test:unit": "node -r esm ./syntax/test/literals.js",
"test": "npm run --silent test:fixtures && npm run --silent test:unit",
"test:format": "node ./build/format/test/resolver.js ./format/spec/",
"test": "npm run --silent test:fixtures && npm run --silent test:unit && npm run --silent test:format",
"watch": "tsc --watch"
},
"homepage": "https://projectfluent.org",
Expand Down

0 comments on commit 7cd8fc0

Please sign in to comment.