@@ -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,29 @@ 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 ( 'user config wot block overrides defaults' , ( ) => {
276+ const defaults = SettingsStatic . loadAndParseYamlFile (
277+ SettingsStatic . getDefaultSettingsFilePath ( )
278+ )
279+ const userConfig = { wot : { enabled : true , seedPubkey : 'abc123' , minimumFollowers : 3 } }
280+ const merged = mergeDeepRight ( defaults , userConfig ) as Settings
281+ expect ( merged . wot ?. enabled ) . to . equal ( true )
282+ expect ( merged . wot ?. seedPubkey ) . to . equal ( 'abc123' )
283+ expect ( merged . wot ?. minimumFollowers ) . to . equal ( 3 )
284+ // non-overridden fields stay as defaults
285+ expect ( merged . wot ?. refreshIntervalHours ) . to . equal ( 24 )
286+ } )
287+ } )
261288} )
0 commit comments