Internationalization
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { loadI18n } from '../test-support/i18n.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
@@ -8,6 +9,7 @@ async function load(name, options = {}) {
|
||||
const filename = path.resolve(import.meta.dirname, '../public/js', name);
|
||||
const context = { Wegwichtel: { Config: { apiBase: '/api', routeRadiusKm: 5, geolocationTimeoutMs: 7000 } }, ...options };
|
||||
context.globalThis = context;
|
||||
await loadI18n(context);
|
||||
vm.runInNewContext(await fs.readFile(filename, 'utf8'), context, { filename });
|
||||
return context;
|
||||
}
|
||||
@@ -63,10 +65,10 @@ test('GPS normalizes positions, forwards errors and clears replaced watches incl
|
||||
test('GPS unsupported devices reject current location and optionally report tracking errors', async () => {
|
||||
for (const navigator of [undefined, {}]) {
|
||||
const { Wegwichtel: ns } = await load('geolocation.js', { navigator });
|
||||
await assert.rejects(ns.Geo.current(), /keine Geolokalisierung/);
|
||||
await assert.rejects(ns.Geo.current(), /Standort nicht finden/);
|
||||
const errors = [];
|
||||
ns.Geo.start(() => assert.fail('unexpected position'), error => errors.push(error));
|
||||
assert.match(errors[0].message, /keine Geolokalisierung/);
|
||||
assert.match(errors[0].message, /Standort nicht finden/);
|
||||
ns.Geo.start(() => {});
|
||||
ns.Geo.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user