Skip to content
Source
Sign inSign up

nativeLanguage.test.ts

18 lines869 Bytes

1import { expect, it } from "vite-plus/test";
2​
3import { nativeSpeechLanguage } from "./nativeLanguage.ts";
4​
5const nemotron = ["en-US", "en-GB", "es-US", "es-ES", "de-DE"];
6​
7it.each([
8 ["auto omits the hint", nemotron, "auto", undefined],
9 ["exact entry", ["en", "de"], "de", "de"],
10 ["exact entry before a regional one", ["de-DE", "de"], "de", "de"],
11 ["case and underscore normalize to the advertised spelling", nemotron, "DE_de", "de-DE"],
12 ["bare code takes the first regional entry", nemotron, "en", "en-US"],
13 ["regional request with another region passes through", nemotron, "de-AT", "de-AT"],
14 ["unadvertised language passes through", nemotron, "fr", "fr"],
15 ["model without an advertised list passes through", [], "de", "de"],
16])("%s", (_name, advertised, language, expected) => {
17 expect(nativeSpeechLanguage(advertised, language)).toBe(expected);
18});