diff --git a/format/test/resolver.ts b/format/test/resolver.ts new file mode 100644 index 0000000..097a01d --- /dev/null +++ b/format/test/resolver.ts @@ -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); +} diff --git a/package.json b/package.json index a132cfa..efa9a9b 100644 --- a/package.json +++ b/package.json @@ -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",