From a64b32d12c4c5087f3e68902d1f720892c8859c0 Mon Sep 17 00:00:00 2001 From: Karel De Smet Date: Tue, 22 Dec 2020 21:12:53 +0100 Subject: [PATCH] Test for toBeType() --- helpers/__tests__/postwomanTesting.spec.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/helpers/__tests__/postwomanTesting.spec.js b/helpers/__tests__/postwomanTesting.spec.js index fbd77e7cb..1afa61622 100644 --- a/helpers/__tests__/postwomanTesting.spec.js +++ b/helpers/__tests__/postwomanTesting.spec.js @@ -166,3 +166,29 @@ describe("toHaveLength()", () => { expect(getTestResult(`pw.expect(${fruits}).not.toHaveLength(7)`, 0)).toEqual(PASS) }) }) + +describe("toBeType()", () => { + test("test for positive assertion", () => { + expect(getTestResult("pw.expect('random').toBeType('string')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(true).toBeType('boolean')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(5).toBeType('number')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(new Date()).toBeType('object')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(undefined).toBeType('undefined')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(BigInt(123)).toBeType('bigint')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(Symbol('test')).toBeType('symbol')", 0)).toEqual(PASS) + expect(getTestResult("pw.expect(function() {}).toBeType('function')", 0)).toEqual(PASS) + }) + test("test for negative assertion", () => { + expect(getTestResult("pw.expect('random').not.toBeType('string')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(true).not.toBeType('boolean')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(5).not.toBeType('number')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(new Date()).not.toBeType('object')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(undefined).not.toBeType('undefined')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(BigInt(123)).not.toBeType('bigint')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(Symbol('test')).not.toBeType('symbol')", 0)).toEqual(FAIL) + expect(getTestResult("pw.expect(function() {}).not.toBeType('function')", 0)).toEqual(FAIL) + }) + test("unexpected type", () => { + expect(getTestResult("pw.expect('random').toBeType('unknown')", 0)).toEqual(FAIL) + }) +})