/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import assert from 'node:assert/strict'; import test from 'node:test'; import { ENFORCE_CHECK_FIELDS, normalizeContentGuardConfig, } from './contentGuardConfig.js'; test('normalizeContentGuardConfig enables every check in enforce mode', () => { const config = normalizeContentGuardConfig({ enabled: true, mode: 'enforce', confirm_enforce: true, input_enabled: false, output_enabled: undefined, text_enabled: 0, image_enabled: null, video_enabled: '', }); for (const field of ENFORCE_CHECK_FIELDS) { assert.equal(config[field], true, `${field} should be enabled`); } assert.equal(config.enabled, true); assert.equal(config.confirm_enforce, true); }); test('normalizeContentGuardConfig converts form booleans explicitly', () => { const config = normalizeContentGuardConfig({ enabled: 0, mode: 'observe', confirm_enforce: undefined, input_enabled: true, output_enabled: false, text_enabled: 1, image_enabled: null, video_enabled: '', }); assert.deepEqual( { enabled: config.enabled, confirm_enforce: config.confirm_enforce, input_enabled: config.input_enabled, output_enabled: config.output_enabled, text_enabled: config.text_enabled, image_enabled: config.image_enabled, video_enabled: config.video_enabled, }, { enabled: false, confirm_enforce: false, input_enabled: true, output_enabled: false, text_enabled: true, image_enabled: false, video_enabled: false, }, ); });