mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-03 17:38:36 +00:00
Compare commits
5 Commits
feat/node_
...
release/v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b0bdf0542 | ||
|
|
1987932518 | ||
|
|
3712d88201 | ||
|
|
dd108b8d0f | ||
|
|
90b31ff880 |
@@ -46,7 +46,7 @@ const Docs = ({ collection }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledWrapper className="mt-1 h-full w-full relative flex flex-col">
|
||||
<StyledWrapper className="h-full w-full relative flex flex-col">
|
||||
<div className='flex flex-row w-full justify-between items-center mb-4'>
|
||||
<div className='text-lg font-medium flex items-center gap-2'>
|
||||
<IconFileText size={20} strokeWidth={1.5} />
|
||||
|
||||
@@ -132,7 +132,7 @@ const CollectionSettings = ({ collection }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledWrapper className="flex flex-col h-full relative px-4 py-4 overflow-scroll">
|
||||
<StyledWrapper className="flex flex-col h-full relative px-4 py-4 overflow-hidden">
|
||||
<div className="flex flex-wrap items-center tabs" role="tablist">
|
||||
<div className={getTabClassname('overview')} role="tab" onClick={() => setTab('overview')}>
|
||||
Overview
|
||||
@@ -169,7 +169,7 @@ const CollectionSettings = ({ collection }) => {
|
||||
{clientCertConfig.length > 0 && <StatusDot />}
|
||||
</div>
|
||||
</div>
|
||||
<section className="mt-4 h-full overflow-scroll">{getTabPanel(tab)}</section>
|
||||
<section className="mt-4 h-full overflow-auto">{getTabPanel(tab)}</section>
|
||||
</StyledWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ const FolderSettings = ({ collection, folder }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledWrapper className="flex flex-col h-full overflow-scroll">
|
||||
<StyledWrapper className="flex flex-col h-full overflow-auto">
|
||||
<div className="flex flex-col h-full relative px-4 py-4">
|
||||
<div className="flex flex-wrap items-center tabs" role="tablist">
|
||||
<div className={getTabClassname('headers')} role="tab" onClick={() => setTab('headers')}>
|
||||
@@ -101,7 +101,7 @@ const FolderSettings = ({ collection, folder }) => {
|
||||
Docs
|
||||
</div>
|
||||
</div>
|
||||
<section className={`flex mt-4 h-full overflow-scroll`}>{getTabPanel(tab)}</section>
|
||||
<section className={`flex mt-4 h-full overflow-auto`}>{getTabPanel(tab)}</section>
|
||||
</div>
|
||||
</StyledWrapper>
|
||||
);
|
||||
|
||||
@@ -109,7 +109,7 @@ const Auth = ({ item, collection }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledWrapper className="w-full mt-1 overflow-y-scroll">
|
||||
<StyledWrapper className="w-full mt-1 overflow-auto">
|
||||
<div className="flex flex-grow justify-start items-center">
|
||||
<AuthMode item={item} collection={collection} />
|
||||
</div>
|
||||
|
||||
@@ -176,7 +176,7 @@ const ResponsePane = ({ item, collection }) => {
|
||||
) : null}
|
||||
</div>
|
||||
<section
|
||||
className={`flex flex-col min-h-0 relative px-4 auto overflow-scroll`}
|
||||
className={`flex flex-col min-h-0 relative px-4 auto overflow-auto`}
|
||||
style={{
|
||||
flex: '1 1 0',
|
||||
height: hasScriptError && showScriptErrorCard ? 'auto' : '100%'
|
||||
|
||||
@@ -96,7 +96,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledWrapper className="flex flex-col h-full relative overflow-scroll">
|
||||
<StyledWrapper className="flex flex-col h-full relative overflow-auto">
|
||||
<div className="flex items-center tabs overflow-visible" role="tablist">
|
||||
<div className={getTabClassname('response')} role="tab" onClick={() => selectTab('response')}>
|
||||
Response
|
||||
@@ -128,7 +128,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
|
||||
<ResponseSize size={size} />
|
||||
</div>
|
||||
</div>
|
||||
<section className="flex flex-col flex-grow overflow-scroll">
|
||||
<section className="flex flex-col flex-grow overflow-auto">
|
||||
{hasScriptError && showScriptErrorCard && (
|
||||
<ScriptError
|
||||
item={item}
|
||||
|
||||
@@ -180,7 +180,7 @@ export default function RunnerResults({ collection }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledWrapper className="px-4 pb-4 flex flex-grow flex-col relative overflow-scroll">
|
||||
<StyledWrapper className="px-4 pb-4 flex flex-grow flex-col relative overflow-auto">
|
||||
<div className="flex flex-row">
|
||||
<div className="font-medium my-6 title flex items-center">
|
||||
Runner
|
||||
|
||||
@@ -5,12 +5,12 @@ const StyledWrapper = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 16px;
|
||||
height: 22px;
|
||||
padding: 0 1rem;
|
||||
height: 1.5rem;
|
||||
background: ${(props) => props.theme.sidebar.bg};
|
||||
border-top: 1px solid ${(props) => props.theme.statusBar.border};
|
||||
color: ${(props) => props.theme.sidebar.color};
|
||||
font-size: 12px;
|
||||
color: ${(props) => props.theme.statusBar.color};
|
||||
font-size: 0.75rem;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
}
|
||||
@@ -32,9 +32,7 @@ const StyledWrapper = styled.div`
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 4px;
|
||||
color: ${(props) => props.theme.sidebar.color};
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
position: relative;
|
||||
outline: none;
|
||||
}
|
||||
@@ -43,13 +41,11 @@ const StyledWrapper = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
gap: 0.25rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.console-label {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -66,17 +62,13 @@ const StyledWrapper = styled.div`
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
background: ${(props) => props.theme.sidebar.dragbar};
|
||||
margin: 0 8px;
|
||||
opacity: 0.3;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.status-bar-version {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
font-size: 10px;
|
||||
color: ${(props) => props.theme.sidebar.muted};
|
||||
font-family: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@@ -71,18 +71,6 @@ const StatusBar = () => {
|
||||
</button>
|
||||
</ToolHint>
|
||||
|
||||
<ToolHint text="Cookies" toolhintId="Cookies" place="top" offset={10}>
|
||||
<button
|
||||
className="status-bar-button"
|
||||
data-trigger="cookies"
|
||||
onClick={() => setCookiesOpen(true)}
|
||||
tabIndex={0}
|
||||
aria-label="Open Cookies Settings"
|
||||
>
|
||||
<IconCookie size={16} strokeWidth={1.5} aria-hidden="true" />
|
||||
</button>
|
||||
</ToolHint>
|
||||
|
||||
<ToolHint text="Notifications" toolhintId="Notifications" place="top" offset={10}>
|
||||
<div className="status-bar-button">
|
||||
<Notifications />
|
||||
@@ -92,7 +80,20 @@ const StatusBar = () => {
|
||||
</div>
|
||||
|
||||
<div className="status-bar-section">
|
||||
<div className="status-bar-group">
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
className="status-bar-button"
|
||||
data-trigger="cookies"
|
||||
onClick={() => setCookiesOpen(true)}
|
||||
tabIndex={0}
|
||||
aria-label="Open Cookies"
|
||||
>
|
||||
<div className="console-button-content">
|
||||
<IconCookie size={16} strokeWidth={1.5} aria-hidden="true" />
|
||||
<span className="console-label">Cookies</span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className={`status-bar-button ${errorCount > 0 ? 'has-errors' : ''}`}
|
||||
data-trigger="dev-tools"
|
||||
@@ -100,13 +101,13 @@ const StatusBar = () => {
|
||||
tabIndex={0}
|
||||
aria-label={`Open Dev Tools${errorCount > 0 ? ` (${errorCount} errors)` : ''}`}
|
||||
>
|
||||
<div className="console-button-content">
|
||||
<IconTool size={16} strokeWidth={1.5} aria-hidden="true" />
|
||||
<span className="console-label">Dev Tools</span>
|
||||
{errorCount > 0 && (
|
||||
<span className="error-count-inline">{errorCount}</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="console-button-content">
|
||||
<IconTool size={16} strokeWidth={1.5} aria-hidden="true" />
|
||||
<span className="console-label">Dev Tools</span>
|
||||
{errorCount > 0 && (
|
||||
<span className="error-count-inline">{errorCount}</span>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div className="status-bar-divider"></div>
|
||||
|
||||
@@ -89,7 +89,7 @@ const VariablesEditor = ({ collection }) => {
|
||||
const reactInspectorTheme = storedTheme === 'light' ? 'chromeLight' : 'chromeDark';
|
||||
|
||||
return (
|
||||
<StyledWrapper className="px-4 py-4 overflow-scroll">
|
||||
<StyledWrapper className="px-4 py-4 overflow-auto">
|
||||
<RuntimeVariables collection={collection} theme={reactInspectorTheme} />
|
||||
<EnvVariables collection={collection} theme={reactInspectorTheme} />
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const initialState = {
|
||||
isEnvironmentSettingsModalOpen: false,
|
||||
preferences: {
|
||||
request: {
|
||||
sslVerification: false,
|
||||
sslVerification: true,
|
||||
customCaCertificate: {
|
||||
enabled: false,
|
||||
filePath: null
|
||||
|
||||
@@ -299,6 +299,7 @@ const darkTheme = {
|
||||
|
||||
statusBar: {
|
||||
border: '#323233',
|
||||
color: 'rgb(169, 169, 169)'
|
||||
},
|
||||
console: {
|
||||
bg: '#1e1e1e',
|
||||
|
||||
@@ -300,6 +300,7 @@ const lightTheme = {
|
||||
|
||||
statusBar: {
|
||||
border: '#E9E9E9',
|
||||
color: 'rgb(100, 100, 100)'
|
||||
},
|
||||
console: {
|
||||
bg: '#f8f9fa',
|
||||
|
||||
@@ -287,6 +287,10 @@ const runSingleRequest = async function (
|
||||
https_proxy,
|
||||
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||
);
|
||||
} else {
|
||||
request.httpsAgent = new https.Agent({
|
||||
...httpsAgentRequestFields
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Invalid system https_proxy');
|
||||
|
||||
@@ -10,7 +10,7 @@ const { get, merge } = require('lodash');
|
||||
|
||||
const defaultPreferences = {
|
||||
request: {
|
||||
sslVerification: false,
|
||||
sslVerification: true,
|
||||
customCaCertificate: {
|
||||
enabled: false,
|
||||
filePath: null
|
||||
@@ -27,7 +27,7 @@ const defaultPreferences = {
|
||||
codeFontSize: 14
|
||||
},
|
||||
proxy: {
|
||||
mode: 'system',
|
||||
mode: 'off',
|
||||
protocol: 'http',
|
||||
hostname: '',
|
||||
port: null,
|
||||
@@ -132,7 +132,7 @@ const savePreferences = async (newPreferences) => {
|
||||
|
||||
const preferencesUtil = {
|
||||
shouldVerifyTls: () => {
|
||||
return get(getPreferences(), 'request.sslVerification', false);
|
||||
return get(getPreferences(), 'request.sslVerification', true);
|
||||
},
|
||||
shouldUseCustomCaCertificate: () => {
|
||||
return get(getPreferences(), 'request.customCaCertificate.enabled', false);
|
||||
|
||||
@@ -368,6 +368,9 @@ function setupProxyAgents({
|
||||
{ proxy: https_proxy,...tlsOptions },
|
||||
timeline
|
||||
);
|
||||
} else {
|
||||
const TimelineHttpsAgent = createTimelineAgentClass(https.Agent);
|
||||
requestConfig.httpsAgent = new TimelineHttpsAgent(tlsOptions, timeline);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Invalid system https_proxy');
|
||||
|
||||
@@ -67,10 +67,9 @@ const grammar = ohm.grammar(`Bru {
|
||||
textchar = ~nl any
|
||||
|
||||
// List
|
||||
listend = stnl* "]"
|
||||
list = st* "[" listitems? listend
|
||||
listitems = (~listend stnl)* listitem (~listend stnl* listitem)* (~listend space)*
|
||||
listitem = st* textchar+ st*
|
||||
list = st* "[" nl+ listitems? st* nl+ st* "]"
|
||||
listitems = listitem (nl+ listitem)*
|
||||
listitem = st+ (alnum | "_" | "-")+ st*
|
||||
|
||||
meta = "meta" dictionary
|
||||
settings = "settings" dictionary
|
||||
@@ -318,10 +317,10 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
||||
assertkey(chars) {
|
||||
return chars.sourceString ? chars.sourceString.trim() : '';
|
||||
},
|
||||
list(_1, _2, listitems, _3) {
|
||||
list(_1, _2, _3, listitems, _4, _5, _6, _7) {
|
||||
return listitems.ast.flat()
|
||||
},
|
||||
listitems(_1, listitem, _2, rest, _3) {
|
||||
listitems(listitem, _1, rest) {
|
||||
return [listitem.ast, ...rest.ast]
|
||||
},
|
||||
listitem(_1, textchar, _2) {
|
||||
|
||||
798
packages/bruno-lang/v2/tests/list.spec.js
Normal file
798
packages/bruno-lang/v2/tests/list.spec.js
Normal file
@@ -0,0 +1,798 @@
|
||||
/**
|
||||
* This test file is used to test list parsing in various BruFile blocks.
|
||||
*/
|
||||
const parser = require('../src/bruToJson');
|
||||
|
||||
describe('List Support in BruFile Blocks', () => {
|
||||
|
||||
describe('Basic List Functionality', () => {
|
||||
describe('Valid List Syntax', () => {
|
||||
it('should parse simple list with proper indentation', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
tags: ['tag_1', 'tag_2'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse list with mixed properties', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: request_name
|
||||
tags: [
|
||||
regression
|
||||
smoke_test
|
||||
]
|
||||
type: http
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
name: "request_name",
|
||||
tags: ['regression', 'smoke_test'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse list with varying indentation inside list', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
tag_3
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
tags: ['tag_1', 'tag_2', 'tag_3'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse list with alphanumeric, underscore, and hyphen characters', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag-with-hyphens
|
||||
tag_with_underscores
|
||||
tag123numbers
|
||||
CamelCaseTag
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
tags: ['tag-with-hyphens', 'tag_with_underscores', 'tag123numbers', 'CamelCaseTag'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Invalid List Syntax', () => {
|
||||
it('should fail when list items have no indentation', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list has empty lines between items', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list opening bracket is on same line as first item', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list closing bracket is on same line as last item', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list items contain invalid characters - variation 1', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag*1
|
||||
tag@2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list items contain spaces', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag with spaces
|
||||
another-tag
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list items contain invalid characters - variation 2', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1,
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when first list item has no indentation', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [ tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should fail when list item are not seperated by atleast one newline', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2 tag_3
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
|
||||
it('should not parse empty list', () => {
|
||||
const input = `
|
||||
meta {
|
||||
tags: [
|
||||
]
|
||||
}
|
||||
`;
|
||||
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('String Values That Look Like Lists', () => {
|
||||
it('should parse inline bracketed strings as regular values', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [some name]
|
||||
tags: [
|
||||
actual_list_item
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
name: "[some name]",
|
||||
tags: ['actual_list_item'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bracketed strings with spaces as regular values', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [ this is the name ]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
name: "[ this is the name ]",
|
||||
tags: ['tag_1', 'tag_2'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should fail when multiline bracketed strings are malformed', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [this spans
|
||||
multiple lines
|
||||
]
|
||||
}
|
||||
`;
|
||||
expect(() => parser(input)).toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Lists in Meta Block', () => {
|
||||
it('should parse tags in meta block', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: API Test
|
||||
tags: [
|
||||
api
|
||||
integration
|
||||
v1
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "API Test",
|
||||
tags: ['api', 'integration', 'v1'],
|
||||
seq: 1,
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse custom list properties in meta block', () => {
|
||||
const input = `
|
||||
meta {
|
||||
categories: [
|
||||
user-management
|
||||
auth
|
||||
]
|
||||
environments: [
|
||||
staging
|
||||
production
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
const expected = {
|
||||
meta: {
|
||||
seq: 1,
|
||||
categories: ['user-management', 'auth'],
|
||||
environments: ['staging', 'production'],
|
||||
type: "http"
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Lists type content in Body Blocks', () => {
|
||||
it('should parse bru file with a text body block that has list type values - variation 1', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:text {
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
text: `meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a text body block that has list type values - variation 2', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:text {
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
text: `meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has list type values - variation 1', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has list type values - variation 2', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has array values', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
{
|
||||
array: [
|
||||
"1",
|
||||
"2",
|
||||
"3"
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `{
|
||||
array: [
|
||||
"1",
|
||||
"2",
|
||||
"3"
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has array of objects - variation 1', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
{
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `{
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has array of objects - variation 2', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
[{
|
||||
"foo": "bar"
|
||||
}]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `[{
|
||||
"foo": "bar"
|
||||
}]`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has array of objects - variation 3', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
[{"foo": "bar"}]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `[{"foo": "bar"}]`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block that has objects and arrays - variation 1', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
{
|
||||
object: {
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `{
|
||||
object: {
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should parse bru file with a json body block with complex arrays', () => {
|
||||
const input = `
|
||||
meta {
|
||||
name: [name]
|
||||
tags: [
|
||||
tag_1
|
||||
tag_2
|
||||
]
|
||||
}
|
||||
body:json {
|
||||
[
|
||||
"string",
|
||||
array: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
object: {
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`;
|
||||
const output = parser(input);
|
||||
|
||||
const expected = {
|
||||
meta: {
|
||||
name: "[name]",
|
||||
tags: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
seq: 1,
|
||||
type: 'http'
|
||||
},
|
||||
body: {
|
||||
json: `[
|
||||
"string",
|
||||
array: [
|
||||
"tag_1",
|
||||
"tag_2"
|
||||
],
|
||||
object: {
|
||||
array: [
|
||||
{
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"id": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]`
|
||||
}
|
||||
};
|
||||
expect(output).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user