From 3f9a1c08cc70ac5bfc21bff13ef51eea1bd06f27 Mon Sep 17 00:00:00 2001 From: David Laban Date: Thu, 27 Dec 2018 11:49:34 +0000 Subject: [PATCH] Add tests for babel-types.isType (#9243) --- packages/babel-types/test/validators.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index f285b11056..4b59edeb27 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -122,4 +122,19 @@ describe("validators", function() { expect(t.isReferenced(node, parent)).toBe(true); }); }); + + describe("isType", function() { + it("returns true if nodeType equals targetType", function() { + expect(t.isType("Identifier", "Identifier")).toBe(true); + }); + it("returns false if targetType is a primary node type", function() { + expect(t.isType("Expression", "ArrayExpression")).toBe(false); + }); + it("returns true if targetType is an alias of nodeType", function() { + expect(t.isType("ArrayExpression", "Expression")).toBe(true); + }); + it("returns false if nodeType and targetType are unrelated", function() { + expect(t.isType("ArrayExpression", "ClassBody")).toBe(false); + }); + }); });