mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-28 15:14:06 +00:00
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:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user