|
| 1 | +The files in this directory were originally copied from the [messageformat project](https://github.com/messageformat/messageformat/tree/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/__fixtures) |
| 2 | +and are here relicensed by their original author (Eemeli Aro) under the Unicode License. |
| 3 | + |
| 4 | +These test files are intended to be useful for testing multiple different message processors in different ways: |
| 5 | + |
| 6 | +- `syntax-errors.json` — An array of strings that should produce a Syntax Error or a Data Model Error when parsed. |
| 7 | + |
| 8 | +- `test-core.json` — An array of test cases that do not depend on any registry definitions. |
| 9 | + Each test may include some of the following fields: |
| 10 | + - `src: string` (required) — The MF2 syntax source. |
| 11 | + - `exp: string` (required) — The expected result of formatting the message to a string. |
| 12 | + - `locale: string` — The locale to use for formatting. Defaults to 'en-US'. |
| 13 | + - `params: Record<string, string | number | null | undefined>` — Parameters to pass in to the formatter for resolving external variables. |
| 14 | + - `parts: object[]` — The expected result of formatting the message to parts. |
| 15 | + - `cleanSrc: string` — A normalixed form of `src`, for testing stringifiers. |
| 16 | + - `errors: { type: string }[]` — The runtime errors expected to be emitted when formatting the message. |
| 17 | + - `only: boolean` — Normally not set. A flag to use during development to only run one or more specific tests. |
| 18 | + |
| 19 | +- `test-function.json` — An object with string keys and arrays of test cases as values, |
| 20 | + using the same definition as for `test-core.json`. |
| 21 | + The keys each correspond to a function that is used in the tests. |
| 22 | + |
| 23 | +TypeScript `.d.ts` files are included for `test-core.json` and `test-function.json` with the above definition. |
| 24 | + |
| 25 | +Some examples of test harnesses using these tests, from the source repository: |
| 26 | +- [CST parse/stringify tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/cst/cst.test.ts) |
| 27 | +- [Data model stringify tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/data-model/stringify.test.ts) |
| 28 | +- [Formatting tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/messageformat.test.ts) |
0 commit comments