From 3614f5b6201a1a5bf57a79d7819afb401dbae8ea Mon Sep 17 00:00:00 2001 From: Karel De Smet Date: Mon, 21 Dec 2020 17:35:40 +0100 Subject: [PATCH] Test for toBeLevel2xx() --- helpers/__tests__/postwomanTesting.spec.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/helpers/__tests__/postwomanTesting.spec.js b/helpers/__tests__/postwomanTesting.spec.js index e0824ec41..1bf16a060 100644 --- a/helpers/__tests__/postwomanTesting.spec.js +++ b/helpers/__tests__/postwomanTesting.spec.js @@ -62,3 +62,25 @@ describe("toHaveProperty", () => { ).toEqual(FAIL) }) }) + +describe("toBeLevel2xx", () => { + test("test for numbers", () => { + expect(getTestResult("pw.expect(200).toBeLevel2xx()", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(200).not.toBeLevel2xx()", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(300).toBeLevel2xx()", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(300).not.toBeLevel2xx()", 0)).toEqual(PASS) + }) + test("test for strings", () => { + expect(getTestResult("pw.expect('200').toBeLevel2xx()", 0)).toEqual(PASS) + expect(getTestResult("pw.expect('200').not.toBeLevel2xx()", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect('300').toBeLevel2xx()", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect('300').not.toBeLevel2xx()", 0)).toEqual(PASS) + }) + test("failed to parse to integer", () => { + expect(getTestResult("pw.expect(undefined).toBeLevel2xx()", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(null).toBeLevel2xx()", 0)).toEqual(FAIL) + expect(() => { + runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel2xx()") + }).toThrow() + }) +})