UNPKG

@mytmpvpn/mytmpvpn-client

Version:

MyTmpVpn Client Library

57 lines (56 loc) 2.62 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const fc = __importStar(require("fast-check")); const logging_1 = require("../src/logging"); describe('Feature: full-logger-migration, Property 2: Client setVerbose round-trip', () => { /** * **Validates: Requirements 2.5, 5.1** * * For any sequence of setVerbose(true) and setVerbose(false) calls, * the client logger shall produce debug-level output in both states, * and trace-level output shall match the current verbose state: * enabled when verbose=true, suppressed when verbose=false. */ it('should toggle trace-level output to match verbose state after each toggle', () => { fc.assert(fc.property(fc.array(fc.boolean(), { minLength: 1, maxLength: 20 }), (boolSequence) => { for (const verbose of boolSequence) { // Install spies BEFORE setVerbose so loglevel captures them const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { }); (0, logging_1.setVerbose)(verbose); // debug-level output should always work logging_1.logger.debug('test-debug-message'); const debugEmitted = debugSpy.mock.calls.length > 0; debugSpy.mockRestore(); // debug should always emit if (!debugEmitted) return false; } // Reset to default state (0, logging_1.setVerbose)(false); return true; }), { numRuns: 100 }); }); });