"Fossies" - the Fresh Open Source Software Archive  

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

toBe.spec.ts  (hoppscotch-2.2.1):toBe.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"
import "@relmify/jest-fp-ts" import "@relmify/jest-fp-ts"
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("toBe", () => { describe("toBe", () => {
describe("general assertion (no negation)", () => { describe("general assertion (no negation)", () => {
test("expect equals expected passes assertion", () => { test("expect equals expected passes assertion", () => {
return expect( return expect(
execTestScript( func(
` `
pw.expect(2).toBe(2) pw.expect(2).toBe(2)
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight([
expect.objectContaining({ expect.objectContaining({
expectResults: [ expectResults: [
{ status: "pass", message: "Expected '2' to be '2'" }, { status: "pass", message: "Expected '2' to be '2'" },
], ],
}), }),
]) ])
}) })
test("expect not equals expected fails assertion", () => { test("expect not equals expected fails assertion", () => {
return expect( return expect(
execTestScript( func(
` `
pw.expect(2).toBe(4) pw.expect(2).toBe(4)
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight([
expect.objectContaining({ expect.objectContaining({
expectResults: [ expectResults: [
{ status: "fail", message: "Expected '2' to be '4'" }, { status: "fail", message: "Expected '2' to be '4'" },
], ],
}), }),
]) ])
}) })
}) })
describe("general assertion (with negation)", () => { describe("general assertion (with negation)", () => {
test("expect equals expected fails assertion", () => { test("expect equals expected fails assertion", () => {
return expect( return expect(
execTestScript( func(
` `
pw.expect(2).not.toBe(2) pw.expect(2).not.toBe(2)
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight([
expect.objectContaining({ expect.objectContaining({
expectResults: [ expectResults: [
{ {
status: "fail", status: "fail",
message: "Expected '2' to not be '2'", message: "Expected '2' to not be '2'",
}, },
], ],
}), }),
]) ])
}) })
test("expect not equals expected passes assertion", () => { test("expect not equals expected passes assertion", () => {
return expect( return expect(
execTestScript( func(
` `
pw.expect(2).not.toBe(4) pw.expect(2).not.toBe(4)
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight([
expect.objectContaining({ expect.objectContaining({
expectResults: [ expectResults: [
{ {
status: "pass", status: "pass",
skipping to change at line 92 skipping to change at line 100
}, },
], ],
}), }),
]) ])
}) })
}) })
}) })
test("strict checks types", () => { test("strict checks types", () => {
return expect( return expect(
execTestScript( func(
` `
pw.expect(2).toBe("2") pw.expect(2).toBe("2")
`, `,
fakeResponse fakeResponse
)() )()
).resolves.toEqualRight([ ).resolves.toEqualRight([
expect.objectContaining({ expect.objectContaining({
expectResults: [ expectResults: [
{ {
status: "fail", status: "fail",
 End of changes. 7 change blocks. 
5 lines changed or deleted 13 lines changed or added

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