From 7633da644045881a25532c492a9f7a89ede5f876 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 4 Apr 2022 13:30:13 -0700 Subject: [PATCH 01/21] Upgrade to @testing-library [dom 8, react 12] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + Added interop for new filterNode option for prettyDom + Fixed misc. tests — JS CHANGELOGS — - https://github.com/testing-library/dom-testing-library/releases/tag/v8.0.0 - https://github.com/testing-library/react-testing-library/releases/tag/v12.0.0 --- lib/src/dom/matches/types.dart | 3 ++- lib/src/dom/pretty_dom.dart | 12 ++++++++++++ lib/src/dom/within.dart | 2 +- lib/src/react/render/render.dart | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/src/dom/matches/types.dart b/lib/src/dom/matches/types.dart index d296c23f..63fb08d6 100644 --- a/lib/src/dom/matches/types.dart +++ b/lib/src/dom/matches/types.dart @@ -77,7 +77,8 @@ abstract class TextMatch { /// the value they provided as the `TextMatch` argument. static Object? Function(Object? originalMessage, Element container) _replaceDartInteropFunctionStringWith( Object? newValue) { - final dartInteropFunctionValueRegex = RegExp(r'([\"`]*)(function[\s\S]+})([\"`]*)(.*)([\s\S]+)*', multiLine: true); + final dartInteropFunctionValueRegex = + RegExp(r'''([\"`]*)(function[\s\S]+})([\"`]*)(?:'\))*(.*)([\s\S]+)*''', multiLine: true); return (originalMessage, container) { final newMessage = originalMessage.toString().replaceAllMapped(dartInteropFunctionValueRegex, (match) { diff --git a/lib/src/dom/pretty_dom.dart b/lib/src/dom/pretty_dom.dart index 77a1971a..b3913313 100644 --- a/lib/src/dom/pretty_dom.dart +++ b/lib/src/dom/pretty_dom.dart @@ -47,6 +47,7 @@ import 'package:js/js.dart'; /// {@macro prettyDomOptionsIndent} /// {@macro prettyDomOptionsMaxDepth} /// {@macro prettyDomOptionsMin} +/// {@macro prettyDomOptionsFilterNode} /// /// > **At this time, formatting plugins and syntax highlighting are not supported.** /// @@ -57,11 +58,13 @@ String prettyDOM( int? indent, int? maxDepth, bool? min, + bool? Function(Node?)? filterNode, }) { final options = PrettyDomOptions(); if (indent != null) options.indent = indent; if (maxDepth != null) options.maxDepth = maxDepth; if (min != null) options.min = min; + if (filterNode != null) options.filterNode = filterNode; return _jsPrettyDOM(node, maxLength, options); } @@ -98,4 +101,13 @@ class PrettyDomOptions { /// {@endtemplate} external bool? get min; external set min(bool? value); + + /// {@template prettyDomOptionsFilterNode} + /// ### [filterNode] + /// By default, `