"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-js-sandbox/src/__tests__/preRequest.spec.ts" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

preRequest.spec.ts  (hoppscotch-2.2.1):preRequest.spec.ts  (hoppscotch-3.0.0)
import { execPreRequestScript } from "../preRequest" import { execPreRequestScript } from "../preRequest"
import "@relmify/jest-fp-ts" import "@relmify/jest-fp-ts"
describe("execPreRequestScript", () => { describe("execPreRequestScript", () => {
test("returns the updated envirionment properly", () => { test("returns the updated envirionment properly", () => {
return expect( return expect(
execPreRequestScript( execPreRequestScript(
` `
pw.env.set("bob", "newbob") pw.env.set("bob", "newbob")
`, `,
[ {
{ key: "bob", value: "oldbob" }, global: [],
{ key: "foo", value: "bar" }, selected: [
] { key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight({
{ key: "bob", value: "newbob" }, global: [],
{ key: "foo", value: "bar" }, selected: [
]) { key: "bob", value: "newbob" },
{ key: "foo", value: "bar" },
],
})
}) })
test("fails if the key is not a string", () => { test("fails if the key is not a string", () => {
return expect( return expect(
execPreRequestScript( execPreRequestScript(
` `
pw.env.set(10, "newbob") pw.env.set(10, "newbob")
`, `,
[ {
{ key: "bob", value: "oldbob" }, global: [],
{ key: "foo", value: "bar" }, selected: [
] { key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)() )()
).resolves.toBeLeft() ).resolves.toBeLeft()
}) })
test("fails if the value is not a string", () => { test("fails if the value is not a string", () => {
return expect( return expect(
execPreRequestScript( execPreRequestScript(
` `
pw.env.set("bob", 10) pw.env.set("bob", 10)
`, `,
[ {
{ key: "bob", value: "oldbob" }, global: [],
{ key: "foo", value: "bar" }, selected: [
] { key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)() )()
).resolves.toBeLeft() ).resolves.toBeLeft()
}) })
test("fails for invalid syntax", () => { test("fails for invalid syntax", () => {
return expect( return expect(
execPreRequestScript( execPreRequestScript(
` `
pw.env.set("bob", pw.env.set("bob",
`, `,
[ {
{ key: "bob", value: "oldbob" }, global: [],
{ key: "foo", value: "bar" }, selected: [
] { key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)() )()
).resolves.toBeLeft() ).resolves.toBeLeft()
}) })
test("creates new env variable if doesn't exist", () => { test("creates new env variable if doesn't exist", () => {
return expect( return expect(
execPreRequestScript( execPreRequestScript(
` `
pw.env.set("foo", "bar") pw.env.set("foo", "bar")
`, `,
[] { selected: [], global: [] }
)() )()
).resolves.toEqualRight([{ key: "foo", value: "bar" }]) ).resolves.toEqualRight({
global: [],
selected: [{ key: "foo", value: "bar" }],
})
}) })
}) })
 End of changes. 7 change blocks. 
22 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)