Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// Generated, do not edit. sha256:3e61f67d82dbe1259a5c61b9f8a08c07ace908e30dd16d94e85cb5c611d6a98a
|
||||
import { describe, it, beforeEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, writeFileSync, readFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { CONFIG } from '../../shared/config.js';
|
||||
import { installLocale, setInstallLocale, adoptInstallLocale } from '../../server/installation.mjs';
|
||||
|
||||
const bestand = () => join(process.env.ASSETAPP_DATA_DIR, CONFIG.INSTALLATION.SETTINGS_FILE_NAME);
|
||||
beforeEach(() => { process.env.ASSETAPP_DATA_DIR = mkdtempSync(join(tmpdir(), 'assetapp-install-')); });
|
||||
|
||||
describe('installatie: de taal', () => {
|
||||
it('begint een nieuwe installatie in de standaardtaal', () => {
|
||||
assert.equal(installLocale(), CONFIG.INSTALLATION.DEFAULT_LOCALE);
|
||||
adoptInstallLocale(undefined);
|
||||
assert.equal(installLocale(), CONFIG.INSTALLATION.DEFAULT_LOCALE);
|
||||
});
|
||||
|
||||
it('neemt de taal van een bestaande portefeuille één keer over', () => {
|
||||
adoptInstallLocale('nl');
|
||||
assert.equal(installLocale(), 'nl');
|
||||
adoptInstallLocale('en');
|
||||
assert.equal(installLocale(), 'nl', 'een volgende start overschrijft de gekozen taal niet');
|
||||
});
|
||||
|
||||
it('neemt geen taal over die de app niet kent', () => {
|
||||
adoptInstallLocale('xx');
|
||||
assert.equal(installLocale(), CONFIG.INSTALLATION.DEFAULT_LOCALE);
|
||||
});
|
||||
|
||||
it('weigert een onbekende taal en laat het bestand staan', () => {
|
||||
setInstallLocale('nl');
|
||||
assert.throws(() => setInstallLocale('xx'), /Unknown locale/);
|
||||
assert.equal(JSON.parse(readFileSync(bestand(), 'utf8')).locale, 'nl');
|
||||
});
|
||||
|
||||
it('houdt andere instellingen in het bestand', () => {
|
||||
writeFileSync(bestand(), JSON.stringify({ toekomst: 1 }));
|
||||
setInstallLocale('nl');
|
||||
assert.deepEqual(JSON.parse(readFileSync(bestand(), 'utf8')), { toekomst: 1, locale: 'nl' });
|
||||
});
|
||||
|
||||
it('gooit bij een kapot bestand in plaats van stil terug te vallen', () => {
|
||||
writeFileSync(bestand(), '{ kapot');
|
||||
assert.throws(() => installLocale(), SyntaxError);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user