Merge branch 'main' of https://github.com/hoppscotch/hoppscotch into main
This commit is contained in:
@@ -87,7 +87,7 @@
|
|||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul v-if="folder.folders.length === 0 && folder.requests.length === 0">
|
<ul v-if="folder.folders && folder.folders.length === 0 && folder.requests && folder.requests.length === 0">
|
||||||
<li class="flex ml-8 border-l border-brdColor">
|
<li class="flex ml-8 border-l border-brdColor">
|
||||||
<p class="info"><i class="material-icons">not_interested</i> {{ $t("folder_empty") }}</p>
|
<p class="info"><i class="material-icons">not_interested</i> {{ $t("folder_empty") }}</p>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
64
helpers/__tests__/postwomanTesting.spec.js
Normal file
64
helpers/__tests__/postwomanTesting.spec.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import { PASS, FAIL } from "../postwomanTesting"
|
||||||
|
import runTestScriptWithVariables from "../postwomanTesting"
|
||||||
|
|
||||||
|
function getTestResult(script, index) {
|
||||||
|
return runTestScriptWithVariables(script).testResults[index].result
|
||||||
|
}
|
||||||
|
|
||||||
|
function getErrors(script) {
|
||||||
|
return runTestScriptWithVariables(script).errors
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("Error handling", () => {
|
||||||
|
test("throws error at unknown test method", () => {
|
||||||
|
const testScriptWithUnknownMethod = "pw.expect(1).toBeSomeUnknownMethod()"
|
||||||
|
expect(() => {
|
||||||
|
runTestScriptWithVariables(testScriptWithUnknownMethod)
|
||||||
|
}).toThrow()
|
||||||
|
})
|
||||||
|
test("errors array is empty on a successful test", () => {
|
||||||
|
expect(getErrors("pw.expect(1).toBe(1)")).toStrictEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("toBe", () => {
|
||||||
|
test("test for numbers", () => {
|
||||||
|
expect(getTestResult("pw.expect(1).toBe(2)", 0)).toEqual(FAIL)
|
||||||
|
|
||||||
|
expect(getTestResult("pw.expect(1).toBe(1)", 0)).toEqual(PASS)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("test for strings", () => {
|
||||||
|
expect(getTestResult("pw.expect('hello').toBe('bonjour')", 0)).toEqual(FAIL)
|
||||||
|
expect(getTestResult("pw.expect('hi').toBe('hi')", 0)).toEqual(PASS)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("test for negative assertion (.not.toBe)", () => {
|
||||||
|
expect(getTestResult("pw.expect(1).not.toBe(1)", 0)).toEqual(FAIL)
|
||||||
|
expect(getTestResult("pw.expect(1).not.toBe(2)", 0)).toEqual(PASS)
|
||||||
|
expect(getTestResult("pw.expect('world').not.toBe('planet')", 0)).toEqual(PASS)
|
||||||
|
expect(getTestResult("pw.expect('world').not.toBe('world')", 0)).toEqual(FAIL)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("toHaveProperty", () => {
|
||||||
|
const dummyResponse = {
|
||||||
|
id: 843,
|
||||||
|
description: "random",
|
||||||
|
}
|
||||||
|
|
||||||
|
test("test for positive assertion (.toHaveProperty)", () => {
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("id")`, 0)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(getTestResult(`pw.expect(${dummyResponse.id}).toBe(843)`, 0)).toEqual(PASS)
|
||||||
|
})
|
||||||
|
test("test for negative assertion (.not.toHaveProperty)", () => {
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).not.toHaveProperty("type")`, 0)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("type")`, 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
const PASS = "PASS"
|
export const PASS = "PASS"
|
||||||
const FAIL = "FAIL"
|
export const FAIL = "FAIL"
|
||||||
const ERROR = "ERROR"
|
export const ERROR = "ERROR"
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
[PASS]: { icon: "check", class: "success-response" },
|
[PASS]: { icon: "check", class: "success-response" },
|
||||||
|
|||||||
Reference in New Issue
Block a user