"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-js-sandbox/src/__tests__/testing/test-runner.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.

test-runner.spec.ts  (hoppscotch-2.2.1):test-runner.spec.ts  (hoppscotch-3.0.0)
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { execTestScript, TestResponse } from "../../test-runner" import { execTestScript, TestResponse } from "../../test-runner"
const fakeResponse: TestResponse = { const fakeResponse: TestResponse = {
status: 200, status: 200,
body: "hoi", body: "hoi",
headers: [], headers: [],
} }
const func = (script: string, res: TestResponse) =>
pipe(
execTestScript(script, { global: [], selected: [] }, res),
TE.map((x) => x.tests)
)
describe("execTestScript function behavior", () => { describe("execTestScript function behavior", () => {
test("returns a resolved promise for a valid test scripts with all green", () => { test("returns a resolved promise for a valid test scripts with all green", () => {
return expect( return expect(
execTestScript( func(
` `
pw.test("Arithmetic operations", () => { pw.test("Arithmetic operations", () => {
const size = 500 + 500; const size = 500 + 500;
pw.expect(size).toBe(1000); pw.expect(size).toBe(1000);
pw.expect(size - 500).toBe(500); pw.expect(size - 500).toBe(500);
pw.expect(size * 4).toBe(4000); pw.expect(size * 4).toBe(4000);
pw.expect(size / 4).toBe(250); pw.expect(size / 4).toBe(250);
}); });
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toBeRight() ).resolves.toBeRight()
}) })
test("resolves for tests with failed expectations", () => { test("resolves for tests with failed expectations", () => {
return expect( return expect(
execTestScript( func(
` `
pw.test("Arithmetic operations", () => { pw.test("Arithmetic operations", () => {
const size = 500 + 500; const size = 500 + 500;
pw.expect(size).toBe(1000); pw.expect(size).toBe(1000);
pw.expect(size - 500).not.toBe(500); pw.expect(size - 500).not.toBe(500);
pw.expect(size * 4).toBe(4000); pw.expect(size * 4).toBe(4000);
pw.expect(size / 4).not.toBe(250); pw.expect(size / 4).not.toBe(250);
}); });
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toBeRight() ).resolves.toBeRight()
}) })
// TODO: We need a more concrete behavior for this // TODO: We need a more concrete behavior for this
test("rejects for invalid syntax on tests", () => { test("rejects for invalid syntax on tests", () => {
return expect( return expect(
execTestScript( func(
` `
pw.test("Arithmetic operations", () => { pw.test("Arithmetic operations", () => {
const size = 500 + 500; const size = 500 + 500;
pw.expect(size). pw.expect(size).
pw.expect(size - 500).not.toBe(500); pw.expect(size - 500).not.toBe(500);
pw.expect(size * 4).toBe(4000); pw.expect(size * 4).toBe(4000);
pw.expect(size / 4).not.toBe(250); pw.expect(size / 4).not.toBe(250);
}); });
`, `,
fakeResponse fakeResponse
 End of changes. 5 change blocks. 
3 lines changed or deleted 11 lines changed or added

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