From 97b473aeabcd005b950355847a692eb8335f5752 Mon Sep 17 00:00:00 2001 From: Claudio Procida Date: Fri, 6 Dec 2019 10:07:21 -0800 Subject: [PATCH] Unit tests for isHTMLBRElement Summary: Adds a unit test for isHTMLBRElement, for the cases null, same document, iframed document Reviewed By: mrkev Differential Revision: D18831442 fbshipit-source-id: af4702f25f7a28cc786078e770023e1c44fdb674 --- .../utils/__tests__/isHTMLBRElement-test.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/component/utils/__tests__/isHTMLBRElement-test.js diff --git a/src/component/utils/__tests__/isHTMLBRElement-test.js b/src/component/utils/__tests__/isHTMLBRElement-test.js new file mode 100644 index 0000000000..4a88b8e805 --- /dev/null +++ b/src/component/utils/__tests__/isHTMLBRElement-test.js @@ -0,0 +1,33 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @emails oncall+draft-js + * @flow strict-local + * @format + */ + +'use strict'; + +const isHTMLBRElement = require('isHTMLBRElement'); + +test('isHTMLBRElement recognizes null', () => { + expect(isHTMLBRElement(null)).toBe(false); +}); + +test('isHTMLBRElement recognizes BR elements in same document', () => { + const br = document.createElement('br'); + expect(isHTMLBRElement(br)).toBe(true); +}); + +test('isHTMLBRElement recognizes BR elements in iframed document', () => { + const iframe = document.createElement('iframe'); + if (document.body != null) { + document.body.appendChild(iframe); + const doc = iframe.contentDocument; + const br = doc.createElement('br'); + expect(isHTMLBRElement(br)).toBe(true); + } +});