refactor: bring js-sandbox project to the monorepo

This commit is contained in:
Andrew Bastin
2021-09-25 00:59:09 +05:30
parent 9698932bde
commit d2865c637c
23 changed files with 1725 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
import { execTestScript, TestResponse } from "../../../test-runner"
import "@relmify/jest-fp-ts"
const fakeResponse: TestResponse = {
status: 200,
body: "hoi",
headers: []
}
describe("toBe", () => {
describe("general assertion (no negation)", () => {
test("expect equals expected passes assertion", () => {
return expect(
execTestScript(
`
pw.expect(2).toBe(2)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [{ status: "pass", message: "Expected '2' to be '2'" }],
}),
])
})
test("expect not equals expected fails assertion", () => {
return expect(
execTestScript(
`
pw.expect(2).toBe(4)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [{ status: "fail", message: "Expected '2' to be '4'" }],
}),
])
})
})
describe("general assertion (with negation)", () => {
test("expect equals expected fails assertion", () => {
return expect(
execTestScript(
`
pw.expect(2).not.toBe(2)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [{
status: "fail",
message: "Expected '2' to not be '2'",
}],
}),
])
})
test("expect not equals expected passes assertion", () => {
return expect(
execTestScript(
`
pw.expect(2).not.toBe(4)
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [{
status: "pass",
message: "Expected '2' to not be '4'",
}],
}),
])
})
})
})
test("strict checks types", () => {
return expect(
execTestScript(
`
pw.expect(2).toBe("2")
`,
fakeResponse
)()
).resolves.toEqualRight([
expect.objectContaining({
expectResults: [{
status: "fail",
message: "Expected '2' to be '2'",
}],
}),
])
})