From dc03b6a76118be6a8f4509c21158904e48bb98d4 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Tue, 7 Feb 2023 04:39:23 +0530 Subject: [PATCH] feat: renamed script:req,res as script:pre-request,post-response --- packages/bruno-lang/v2/src/bruToJson.js | 4 ++-- packages/bruno-lang/v2/src/jsonToBru.js | 4 ++-- packages/bruno-lang/v2/tests/fixtures/request.bru | 2 +- packages/bruno-lang/v2/tests/script.spec.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 3cf65f1b..25bae096 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -80,8 +80,8 @@ const grammar = ohm.grammar(`Bru { bodymultipart = "body:multipart-form" dictionary script = scriptreq | scriptres - scriptreq = "script:req" st* "{" nl* textblock tagend - scriptres = "script:res" st* "{" nl* textblock tagend + scriptreq = "script:pre-request" st* "{" nl* textblock tagend + scriptres = "script:post-response" st* "{" nl* textblock tagend tests = "tests" st* "{" nl* textblock tagend docs = "docs" st* "{" nl* textblock tagend }`); diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index 9d56fa7e..9b7ce146 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -211,7 +211,7 @@ ${indentString(body.xml)} } if(script && script.req && script.req.length) { - bru += `script:req { + bru += `script:pre-request { ${indentString(script.req)} } @@ -219,7 +219,7 @@ ${indentString(script.req)} } if(script && script.res && script.res.length) { - bru += `script:res { + bru += `script:post-response { ${indentString(script.res)} } diff --git a/packages/bruno-lang/v2/tests/fixtures/request.bru b/packages/bruno-lang/v2/tests/fixtures/request.bru index 544a9daf..f2e4fc0e 100644 --- a/packages/bruno-lang/v2/tests/fixtures/request.bru +++ b/packages/bruno-lang/v2/tests/fixtures/request.bru @@ -84,7 +84,7 @@ assert { ~$res.body.message: success } -script:req { +script:pre-request { const foo = 'bar'; } diff --git a/packages/bruno-lang/v2/tests/script.spec.js b/packages/bruno-lang/v2/tests/script.spec.js index c68ddf2e..3ef9da9a 100644 --- a/packages/bruno-lang/v2/tests/script.spec.js +++ b/packages/bruno-lang/v2/tests/script.spec.js @@ -6,7 +6,7 @@ const parser = require("../src/bruToJson"); describe("script parser", () => { it("should parse request script", () => { const input = ` -script:req { +script:pre-request { $req.setHeader('Content-Type', 'application/json'); } `; @@ -22,7 +22,7 @@ script:req { it("should parse response script", () => { const input = ` -script:res { +script:post-response { expect(response.status).to.equal(200); } `;