@@ -2,6 +2,8 @@ import { expect } from 'chai'
22import fs from 'fs'
33import { join } from 'path'
44import Sinon from 'sinon'
5+ import { mergeDeepRight } from 'ramda'
6+ import { Settings } from '../../../src/@types/settings'
57
68import { SettingsFileTypes , SettingsStatic } from '../../../src/utils/settings'
79
@@ -258,4 +260,39 @@ describe('SettingsStatic', () => {
258260 )
259261 } )
260262 } )
263+
264+ describe ( 'WoT settings defaults' , ( ) => {
265+ it ( 'default-settings.yaml contains a wot block with enabled: false' , ( ) => {
266+ const defaults = SettingsStatic . loadAndParseYamlFile (
267+ SettingsStatic . getDefaultSettingsFilePath ( )
268+ )
269+ expect ( defaults ) . to . have . nested . property ( 'wot.enabled' , false )
270+ expect ( defaults ) . to . have . nested . property ( 'wot.seedPubkey' , '' )
271+ expect ( defaults ) . to . have . nested . property ( 'wot.minimumFollowers' , 1 )
272+ expect ( defaults ) . to . have . nested . property ( 'wot.refreshIntervalHours' , 24 )
273+ } )
274+
275+ it ( 'merging an empty user config preserves wot defaults' , ( ) => {
276+ const defaults = SettingsStatic . loadAndParseYamlFile (
277+ SettingsStatic . getDefaultSettingsFilePath ( )
278+ )
279+ const merged = mergeDeepRight ( defaults , { } ) as Settings
280+ expect ( merged . wot ?. enabled ) . to . equal ( false )
281+ expect ( merged . wot ?. minimumFollowers ) . to . equal ( 1 )
282+ expect ( merged . wot ?. refreshIntervalHours ) . to . equal ( 24 )
283+ } )
284+
285+ it ( 'user config wot block overrides defaults' , ( ) => {
286+ const defaults = SettingsStatic . loadAndParseYamlFile (
287+ SettingsStatic . getDefaultSettingsFilePath ( )
288+ )
289+ const userConfig = { wot : { enabled : true , seedPubkey : 'abc123' , minimumFollowers : 3 } }
290+ const merged = mergeDeepRight ( defaults , userConfig ) as Settings
291+ expect ( merged . wot ?. enabled ) . to . equal ( true )
292+ expect ( merged . wot ?. seedPubkey ) . to . equal ( 'abc123' )
293+ expect ( merged . wot ?. minimumFollowers ) . to . equal ( 3 )
294+ // non-overridden fields stay as defaults
295+ expect ( merged . wot ?. refreshIntervalHours ) . to . equal ( 24 )
296+ } )
297+ } )
261298} )
0 commit comments