diff --git a/cli/src/__tests__/utils/options.test.ts b/cli/src/__tests__/utils/options.test.ts index 88175f4a7..f980c64c9 100644 --- a/cli/src/__tests__/utils/options.test.ts +++ b/cli/src/__tests__/utils/options.test.ts @@ -3,12 +3,18 @@ import { handleSaveOptions, handleLoadOptions } from '../../utils/options' import { existsSync, unlinkSync } from 'fs' import { join } from 'path' -import { expect, afterAll, describe, it } from '@jest/globals' +import { expect, afterAll, describe, it, jest, beforeAll } from '@jest/globals' const testFilePath = join(__dirname, 'test-options.json') const defaultPath = join(process.cwd(), 'mqttx-cli-options.json') describe('options', () => { + beforeAll(() => { + global.command = { + getOptionValueSource: jest.fn().mockReturnValue('cli'), + } as any + }) + afterAll(() => { if (existsSync(testFilePath)) { unlinkSync(testFilePath) diff --git a/cli/src/utils/options.ts b/cli/src/utils/options.ts index f85c35eb5..996216975 100644 --- a/cli/src/utils/options.ts +++ b/cli/src/utils/options.ts @@ -35,7 +35,7 @@ const removeUselessOptions = ( */ const filterOptions = (source: OptionValueSource, opts: T): Partial => { return Object.fromEntries( - Object.entries(opts).filter(([key]) => globalThis.command.getOptionValueSource(key) === 'cli'), + Object.entries(opts).filter(([key]) => globalThis.command.getOptionValueSource(key) === source), ) as Partial }