From ad2add402604fdfab33c807a2f8e0d7845403a29 Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <161328623+sanjaikumar-bruno@users.noreply.github.com> Date: Sun, 19 Oct 2025 01:00:19 +0530 Subject: [PATCH] Added tests for replacing invalid variable characters in Postman collection Env (#4634) --------- Co-authored-by: sanjai0py Co-authored-by: Anoop M D --- .../postman-to-bruno/postman-to-bruno.spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js b/packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js index faef24465..953f678e1 100644 --- a/packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js +++ b/packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js @@ -1,5 +1,6 @@ import { describe, it, expect } from '@jest/globals'; import postmanToBruno from '../../../src/postman/postman-to-bruno'; +import { invalidVariableCharacterRegex } from '../../../src/constants'; describe('postman-collection', () => { it('should correctly import a valid Postman collection file', async () => { @@ -7,6 +8,25 @@ describe('postman-collection', () => { expect(brunoCollection).toMatchObject(expectedOutput); }); + it('should replace invalid variable characters with underscores', () => { + const variables = [ + { key: 'validKey', value: 'value1' }, + { key: 'invalid key', value: 'value2' }, + { key: 'another@invalid#key$', value: 'value3' } + ]; + + const processedVariables = variables.map((v) => ({ + name: v.key.replace(invalidVariableCharacterRegex, '_'), + value: v.value + })); + + expect(processedVariables).toEqual([ + { name: 'validKey', value: 'value1' }, + { name: 'invalid_key', value: 'value2' }, + { name: 'another_invalid_key_', value: 'value3' } + ]); + }); + it('should handle falsy values in collection variables', async () => { const collectionWithFalsyVars = { "info": {