Skip to content

Commit

Permalink
Fixed so possible to set params using multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
eijawerner committed Jan 24, 2022
1 parent d9d9a85 commit 88f7d5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
19 changes: 15 additions & 4 deletions e2e_tests/integration/params.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
/* global Cypress, cy, before */

describe(':param in Browser', () => {
before(function() {
cy.visit(Cypress.config('url'))
.title()
.should('include', 'Neo4j Browser')
before(function () {
cy.visit(Cypress.config('url')).title().should('include', 'Neo4j Browser')
cy.wait(3000)
})
it('handles :param without web worker', () => {
Expand Down Expand Up @@ -121,4 +119,17 @@ function runTests() {
cy.resultContains('point({srid:4326, x:12.9082, y:57.7346})')
}
// })

// :params
// it('can set :params with multiple lines syntax', () => {
cy.executeCommand(':clear')
setParamQ = `:params {{} x: 1,{shift}{enter}stringWithSpace:'with space',{shift}{enter}stringWithTab: 'with\ttab'{}}`
cy.executeCommand(setParamQ)
cy.get('[data-testid="rawParamData"]', { timeout: 20000 })
.first()
.should(
'contain',
'{\n "x": 1.0,\n "stringWithSpace": "with space",\n "stringWithTab": "\'with\ttab\'"\n}'
)
// })
}
2 changes: 1 addition & 1 deletion src/shared/modules/commands/helpers/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const handleParamsCommand = (action: any, put: any, targetDb?: any) => {
const param = parts[1].trim()

return Promise.resolve().then(() => {
if (/^"?\{.*\}"?$/.test(param)) {
if (/^"?\{[\s\S]*\}"?$/.test(param)) {
// JSON object string {"x": 2, "y":"string"}
try {
const res = jsonic(param.replace(/^"/, '').replace(/"$/, '')) // Remove any surrounding quotes
Expand Down
2 changes: 2 additions & 0 deletions src/shared/services/commandInterpreterHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const availableCommands = [
})
}
},
// Set params with :param or :params
{
name: 'set-params',
match: (cmd: any) => /^params?\s/.test(cmd),
Expand Down Expand Up @@ -190,6 +191,7 @@ const availableCommands = [
})
}
},
// :params with no parameters just returns what is currently there
{
name: 'params',
match: (cmd: any) => /^params$/.test(cmd),
Expand Down

0 comments on commit 88f7d5e

Please sign in to comment.