(fn: string, opts: Options = {})
| 8 | } from '#packages/babel-plugin-formatjs/types.js' |
| 9 | import {expect, test} from 'vitest' |
| 10 | function transformAndCheck(fn: string, opts: Options = {}) { |
| 11 | const filePath = path.join(import.meta.dirname, 'fixtures', `${fn}.js`) |
| 12 | const messages: ExtractedMessageDescriptor[] = [] |
| 13 | const meta = {} |
| 14 | const {code} = transform(filePath, { |
| 15 | pragma: '@react-intl', |
| 16 | ...opts, |
| 17 | onMsgExtracted(_, msgs) { |
| 18 | messages.push(...msgs) |
| 19 | }, |
| 20 | onMetaExtracted(_, m) { |
| 21 | Object.assign(meta, m) |
| 22 | }, |
| 23 | }) |
| 24 | return { |
| 25 | data: {messages, meta}, |
| 26 | code: code?.trim(), |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | test('additionalComponentNames', function () { |
| 31 | transformAndCheck('additionalComponentNames', { |
no test coverage detected