Added tests for replacing invalid variable characters in Postman collection Env (#4634)

---------

Co-authored-by: sanjai0py <sanjailucifer666@gmail.com>
Co-authored-by: Anoop M D <anoop@usebruno.com>
This commit is contained in:
Sanjai Kumar
2025-10-19 01:00:19 +05:30
committed by GitHub
parent 02554c3ad9
commit ad2add4026

View File

@@ -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": {