diff options
| author | victor | 2026-10-24 15:57:01 +0200 |
|---|---|---|
| committer | victor | 2026-10-24 15:57:01 +0200 |
| commit | 4533910bce394e7a0ee6debfc05ca1221ee51899 (patch) | |
| tree | 73aaa5b2c7a48dbf226e6b81d499ba1a8ecc33a1 /src/i18n/coverage.test.ts | |
| parent | Tilføj dansk (diff) | |
| download | 3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.tar.gz 3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.zip | |
Astra!ny-start
Diffstat (limited to '')
| -rw-r--r-- | src/i18n/coverage.test.ts | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/i18n/coverage.test.ts b/src/i18n/coverage.test.ts deleted file mode 100644 index f12178d..0000000 --- a/src/i18n/coverage.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { describe, expect, it, afterEach } from 'vitest'; -import { defaults, experiments, type Experiment } from '../experiments'; -import { daMeasurementLabels, daWords, setLanguage } from '../i18n'; -import { testLessons, type TestLesson } from '../test4'; -import { danishLessons } from './da'; -import { presentLesson } from './present'; - -const lessons: Experiment[] = [...testLessons, ...experiments]; - -afterEach(() => setLanguage('en')); - -describe('Danish catalog', () => { - it('translates every lesson, control and answer while keeping the mathematics', () => { - setLanguage('da'); - for (const lesson of lessons) { - const copy = danishLessons[lesson.id]; - const view = presentLesson(lesson); - expect(view.title).toBe(copy.title); - expect(view.title).not.toBe(lesson.title); - expect(view.shortTitle).toBe(copy.shortTitle); - expect(view.legend.map(([, text]) => text)).toEqual(copy.legend); - expect(view.controls.map(control => control.id)).toEqual(lesson.controls.map(control => control.id)); - for (const control of view.controls) { - const source = lesson.controls.find(item => item.id === control.id)!; - expect(control.label).toBe(copy.controls[control.id].label); - expect(control.label).not.toBe(source.label); - if (control.kind === 'select' && source.kind === 'select') { - expect(control.options.map(option => option.value)).toEqual(source.options.map(option => option.value)); - expect(control.options.map(option => option.label)).toEqual(source.options.map(option => copy.controls[control.id].options?.[option.value])); - } - } - if (!('questions' in lesson) || !('questions' in view)) continue; - const source = lesson as TestLesson; - const translated = view as TestLesson; - expect(translated.questions).toHaveLength(source.questions.length); - expect(translated.answers).toHaveLength(source.answers.length); - translated.answers.forEach((part, index) => { - expect(part.steps).toHaveLength(source.answers[index].steps.length); - part.steps.forEach((step, stepIndex) => { - expect(step.math).toBe(source.answers[index].steps[stepIndex].math); - expect(step.why).not.toBe(source.answers[index].steps[stepIndex].why); - }); - }); - expect(translated.observe(defaults(lesson))).not.toBe(source.observe(defaults(lesson))); - } - }); - - it('has a Danish label for every live measurement and status word', () => { - const labels = lessons.flatMap(lesson => lesson.measure(defaults(lesson)).map(measurement => measurement.label)); - for (const label of labels) expect(daMeasurementLabels[label], label).toBeTruthy(); - for (const status of ['Repulsive', 'Attractive', 'Inside', 'Outside', 'On surface', 'Undefined', 'pairs']) { - expect(daWords[status], status).toBeTruthy(); - } - setLanguage('da'); - const field = presentLesson(experiments[0]); - expect(field.measure({ ...defaults(field), configuration: 'like' }).map(measurement => measurement.value)).toContain('Frastødende'); - expect(presentLesson(lessons[0]).title).toBe('Arbejde langs en bane'); - setLanguage('en'); - expect(presentLesson(lessons[0]).title).toBe('Work along a path'); - }); -}); |