mirror of
https://github.com/usebruno/bruno.git
synced 2025-08-19 15:46:06 +02:00
feat: res default to bruno query
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const { evaluateJsExpression, internalExpressionCache: cache } = require("../src/utils");
|
||||
const { describe, it, expect } = require("@jest/globals");
|
||||
const { evaluateJsExpression, internalExpressionCache: cache, createResponseParser } = require("../src/utils");
|
||||
|
||||
describe("utils", () => {
|
||||
describe("expression evaluation", () => {
|
||||
@@ -112,4 +113,28 @@ describe("utils", () => {
|
||||
expect(result).toBe(startTime);
|
||||
});
|
||||
});
|
||||
|
||||
describe("response parser", () => {
|
||||
const res = createResponseParser({
|
||||
status: 200,
|
||||
data: {
|
||||
order: {
|
||||
items: [
|
||||
{ id: 1, amount: 10 },
|
||||
{ id: 2, amount: 20 }
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("should default to bruno query", () => {
|
||||
const value = res("..items[?].amount[0]", i => i.amount > 10);
|
||||
expect(value).toBe(20);
|
||||
});
|
||||
|
||||
it("should allow json-query", () => {
|
||||
const value = res.jq("order.items[amount > 10].amount");
|
||||
expect(value).toBe(20);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user