(locale: string, localeData?: any)
| 39 | ) |
| 40 | |
| 41 | export function test(locale: string, localeData?: any): void { |
| 42 | describe(`Intl.NumberFormat ${locale}`, function () { |
| 43 | beforeAll(function () { |
| 44 | if (localeData) { |
| 45 | NumberFormat.__addLocaleData(localeData) |
| 46 | } |
| 47 | }) |
| 48 | it.each(testCombos)( |
| 49 | 'NumberFormat %s, unitDisplay=%s, signDisplay=%s, notation=%s, compactDisplay=%s', |
| 50 | (unitDisplay, signDisplay, notation, compactDisplay) => { |
| 51 | const numberFormatBit = new NumberFormat(locale, { |
| 52 | style: 'unit', |
| 53 | unit: 'bit', |
| 54 | unitDisplay, |
| 55 | signDisplay, |
| 56 | notation, |
| 57 | compactDisplay, |
| 58 | }) |
| 59 | const numberFormatCelsius = new NumberFormat(locale, { |
| 60 | style: 'unit', |
| 61 | unit: 'celsius', |
| 62 | unitDisplay, |
| 63 | signDisplay, |
| 64 | notation, |
| 65 | compactDisplay, |
| 66 | }) |
| 67 | const numberFormatGallon = new NumberFormat(locale, { |
| 68 | style: 'unit', |
| 69 | unit: 'gallon', |
| 70 | unitDisplay, |
| 71 | signDisplay, |
| 72 | notation, |
| 73 | compactDisplay, |
| 74 | }) |
| 75 | |
| 76 | expect(numberFormatBit.formatToParts(10000)).toMatchSnapshot() |
| 77 | expect(numberFormatCelsius.formatToParts(10000)).toMatchSnapshot() |
| 78 | expect(numberFormatGallon.formatToParts(10000)).toMatchSnapshot() |
| 79 | |
| 80 | expect(numberFormatBit.formatRange(10000, 20000)).toMatchSnapshot() |
| 81 | expect(numberFormatCelsius.formatRange(10000, 20000)).toMatchSnapshot() |
| 82 | expect(numberFormatGallon.formatRange(10000, 20000)).toMatchSnapshot() |
| 83 | |
| 84 | expect( |
| 85 | numberFormatBit.formatRangeToParts(10000, 20000) |
| 86 | ).toMatchSnapshot() |
| 87 | expect( |
| 88 | numberFormatCelsius.formatRangeToParts(10000, 20000) |
| 89 | ).toMatchSnapshot() |
| 90 | expect( |
| 91 | numberFormatGallon.formatRangeToParts(10000, 20000) |
| 92 | ).toMatchSnapshot() |
| 93 | } |
| 94 | ) |
| 95 | }) |
| 96 | } |
no test coverage detected