Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ These test files are intended to be useful for testing multiple different messag
- `parts: object[]` — The expected result of formatting the message to parts.
- `cleanSrc: string` — A normalixed form of `src`, for testing stringifiers.
- `errors: { type: string }[]` — The runtime errors expected to be emitted when formatting the message.
If `errors` is either absent or empty, the message must be formatted without errors.
- `only: boolean` — Normally not set. A flag to use during development to only run one or more specific tests.

- `test-function.json` — An object with string keys and arrays of test cases as values,
using the same definition as for `test-core.json`.
The keys each correspond to a function that is used in the tests.
Since the behavior of built-in formatters is implementation-specific,
the `exp` field should generally be omitted,
except for error cases.

TypeScript `.d.ts` files are included for `test-core.json` and `test-function.json` with the above definition.

Expand Down
37 changes: 14 additions & 23 deletions test/test-functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
"exp": "{|horse|}",
"errors": [{ "type": "bad-input" }]
},
{ "src": "{|2006-01-02| :date}", "exp": "1/2/06" },
{ "src": "{|2006-01-02T15:04:06| :date}", "exp": "1/2/06" },
{ "src": "{|2006-01-02| :date style=long}", "exp": "January 2, 2006" },
{ "src": "{|2006-01-02| :date}" },
{ "src": "{|2006-01-02T15:04:06| :date}" },
{ "src": "{|2006-01-02| :date style=long}" },
{
"src": ".local $d = {|2006-01-02| :date style=long} {{{$d :date}}}",
"exp": "January 2, 2006"
"src": ".local $d = {|2006-01-02| :date style=long} {{{$d :date}}}"
},
{
"src": ".local $t = {|2006-01-02T15:04:06| :time} {{{$t :date}}}",
"exp": "1/2/06"
"src": ".local $t = {|2006-01-02T15:04:06| :time} {{{$t :date}}}"
}
],
"time": [
Expand All @@ -25,18 +23,15 @@
"exp": "{|horse|}",
"errors": [{ "type": "bad-input" }]
},
{ "src": "{|2006-01-02T15:04:06| :time}", "exp": "3:04 PM" },
{ "src": "{|2006-01-02T15:04:06| :time}" },
{
"src": "{|2006-01-02T15:04:06| :time style=medium}",
"exp": "3:04:06 PM"
"src": "{|2006-01-02T15:04:06| :time style=medium}"
},
{
"src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t :time}}}",
"exp": "3:04:06 PM"
"src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t :time}}}"
},
{
"src": ".local $d = {|2006-01-02T15:04:06| :date} {{{$d :time}}}",
"exp": "3:04 PM"
"src": ".local $d = {|2006-01-02T15:04:06| :date} {{{$d :time}}}"
}
],
"datetime": [
Expand All @@ -56,23 +51,19 @@
"exp": "{|horse|}",
"errors": [{ "name": "RangeError" }]
},
{ "src": "{|2006-01-02T15:04:06| :datetime}", "exp": "1/2/06, 3:04 PM" },
{ "src": "{|2006-01-02T15:04:06| :datetime}" },
{
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=|2-digit|}",
"exp": "01/2006"
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=|2-digit|}"
},
{
"src": "{|2006-01-02T15:04:06| :datetime dateStyle=long}",
"exp": "January 2, 2006"
"src": "{|2006-01-02T15:04:06| :datetime dateStyle=long}"
},
{
"src": "{|2006-01-02T15:04:06| :datetime timeStyle=medium}",
"exp": "3:04:06 PM"
"src": "{|2006-01-02T15:04:06| :datetime timeStyle=medium}"
},
{
"src": "{$dt :datetime}",
"params": { "dt": "2006-01-02T15:04:06" },
"exp": "1/2/06, 3:04 PM"
"params": { "dt": "2006-01-02T15:04:06" }
}
],
"integer": [
Expand Down