From afabce339b102005a1fd4abe68f661683a2bd4c8 Mon Sep 17 00:00:00 2001 From: Sourcegraph Date: Fri, 26 Apr 2024 04:37:21 +0000 Subject: [PATCH 1/3] Replace mockito with mocktail --- pubspec.yaml | 2 +- test/js_builds/shared_tests.dart | 2 +- test/mockito.mocks.dart | 2 +- test/react_client/event_helpers_test.dart | 84 +++++++++++------------ 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index c533a410..b0455859 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,6 @@ dev_dependencies: dependency_validator: ^3.2.2 glob: ^2.0.0 matcher: ^0.12.11 - mockito: ^5.3.1 + mocktail: ^1.0.3 test: ^1.17.12 workiva_analysis_options: ^1.3.0 diff --git a/test/js_builds/shared_tests.dart b/test/js_builds/shared_tests.dart index 5ccab557..08e5cfa0 100644 --- a/test/js_builds/shared_tests.dart +++ b/test/js_builds/shared_tests.dart @@ -14,7 +14,7 @@ import 'package:react/src/react_client/internal_react_interop.dart'; import 'package:test/test.dart'; void verifyJsFileLoaded(String filename) { - final isLoaded = document.getElementsByTagName('script').any((script) { + final isLoaded = document.getElementsByTagName('script').any()((script) { return Uri.parse((script as ScriptElement).src).pathSegments.last == filename; }); diff --git a/test/mockito.mocks.dart b/test/mockito.mocks.dart index c0eb19d3..ad433ed6 100644 --- a/test/mockito.mocks.dart +++ b/test/mockito.mocks.dart @@ -6,7 +6,7 @@ import 'dart:html' as _i2; import 'dart:math' as _i3; -import 'package:mockito/mockito.dart' as _i1; +import 'package:mocktail/mocktail.dart' as _i1; import 'package:react/src/react_client/synthetic_event_wrappers.dart' as _i4; // ignore_for_file: type=lint diff --git a/test/react_client/event_helpers_test.dart b/test/react_client/event_helpers_test.dart index 4613e5d0..7ce8dcf0 100644 --- a/test/react_client/event_helpers_test.dart +++ b/test/react_client/event_helpers_test.dart @@ -9,7 +9,7 @@ import 'package:react/react_client/js_interop_helpers.dart'; import 'package:react/react_dom.dart'; import 'package:react/react_test_utils.dart'; import 'package:test/test.dart'; -import 'package:mockito/mockito.dart'; +import 'package:mocktail/mocktail.dart'; import '../mockito.mocks.dart'; @@ -106,24 +106,24 @@ main() { final target = DivElement(); final calls = []; - when(nativeKeyboardEvent.bubbles).thenReturn(true); - when(nativeKeyboardEvent.cancelable).thenReturn(true); - when(nativeKeyboardEvent.currentTarget).thenReturn(currentTarget); - when(nativeKeyboardEvent.defaultPrevented).thenReturn(false); - when(nativeKeyboardEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); - when(nativeKeyboardEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); - when(nativeKeyboardEvent.eventPhase).thenReturn(0); - when(nativeKeyboardEvent.target).thenReturn(target); - when(nativeKeyboardEvent.timeStamp).thenReturn(0); - when(nativeKeyboardEvent.type).thenReturn('type'); - when(nativeKeyboardEvent.altKey).thenReturn(false); - when(nativeKeyboardEvent.charCode).thenReturn(0); - when(nativeKeyboardEvent.ctrlKey).thenReturn(false); - when(nativeKeyboardEvent.location).thenReturn(0); - when(nativeKeyboardEvent.keyCode).thenReturn(0); - when(nativeKeyboardEvent.metaKey).thenReturn(false); - when(nativeKeyboardEvent.repeat).thenReturn(false); - when(nativeKeyboardEvent.shiftKey).thenReturn(false); + when(() => nativeKeyboardEvent.bubbles).thenReturn(true); + when(() => nativeKeyboardEvent.cancelable).thenReturn(true); + when(() => nativeKeyboardEvent.currentTarget).thenReturn(currentTarget); + when(() => nativeKeyboardEvent.defaultPrevented).thenReturn(false); + when(() => nativeKeyboardEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); + when(() => nativeKeyboardEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); + when(() => nativeKeyboardEvent.eventPhase).thenReturn(0); + when(() => nativeKeyboardEvent.target).thenReturn(target); + when(() => nativeKeyboardEvent.timeStamp).thenReturn(0); + when(() => nativeKeyboardEvent.type).thenReturn('type'); + when(() => nativeKeyboardEvent.altKey).thenReturn(false); + when(() => nativeKeyboardEvent.charCode).thenReturn(0); + when(() => nativeKeyboardEvent.ctrlKey).thenReturn(false); + when(() => nativeKeyboardEvent.location).thenReturn(0); + when(() => nativeKeyboardEvent.keyCode).thenReturn(0); + when(() => nativeKeyboardEvent.metaKey).thenReturn(false); + when(() => nativeKeyboardEvent.repeat).thenReturn(false); + when(() => nativeKeyboardEvent.shiftKey).thenReturn(false); expect(nativeKeyboardEvent.defaultPrevented, isFalse); @@ -167,28 +167,28 @@ main() { final calls = []; final dataTransfer = MockDataTransfer(); - when(dataTransfer.dropEffect).thenReturn('move'); - - when(nativeMouseEvent.bubbles).thenReturn(true); - when(nativeMouseEvent.cancelable).thenReturn(true); - when(nativeMouseEvent.currentTarget).thenReturn(currentTarget); - when(nativeMouseEvent.defaultPrevented).thenReturn(false); - when(nativeMouseEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); - when(nativeMouseEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); - when(nativeMouseEvent.eventPhase).thenReturn(0); - when(nativeMouseEvent.target).thenReturn(target); - when(nativeMouseEvent.timeStamp).thenReturn(0); - when(nativeMouseEvent.type).thenReturn('type'); - when(nativeMouseEvent.altKey).thenReturn(false); - when(nativeMouseEvent.button).thenReturn(0); - when(nativeMouseEvent.ctrlKey).thenReturn(false); - when(nativeMouseEvent.metaKey).thenReturn(false); - when(nativeMouseEvent.dataTransfer).thenReturn(dataTransfer); - when(nativeMouseEvent.relatedTarget).thenReturn(relatedTarget); - when(nativeMouseEvent.shiftKey).thenReturn(false); - when(nativeMouseEvent.client).thenReturn(Point(1, 2)); - when(nativeMouseEvent.page).thenReturn(Point(3, 4)); - when(nativeMouseEvent.screen).thenReturn(Point(5, 6)); + when(() => dataTransfer.dropEffect).thenReturn('move'); + + when(() => nativeMouseEvent.bubbles).thenReturn(true); + when(() => nativeMouseEvent.cancelable).thenReturn(true); + when(() => nativeMouseEvent.currentTarget).thenReturn(currentTarget); + when(() => nativeMouseEvent.defaultPrevented).thenReturn(false); + when(() => nativeMouseEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); + when(() => nativeMouseEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); + when(() => nativeMouseEvent.eventPhase).thenReturn(0); + when(() => nativeMouseEvent.target).thenReturn(target); + when(() => nativeMouseEvent.timeStamp).thenReturn(0); + when(() => nativeMouseEvent.type).thenReturn('type'); + when(() => nativeMouseEvent.altKey).thenReturn(false); + when(() => nativeMouseEvent.button).thenReturn(0); + when(() => nativeMouseEvent.ctrlKey).thenReturn(false); + when(() => nativeMouseEvent.metaKey).thenReturn(false); + when(() => nativeMouseEvent.dataTransfer).thenReturn(dataTransfer); + when(() => nativeMouseEvent.relatedTarget).thenReturn(relatedTarget); + when(() => nativeMouseEvent.shiftKey).thenReturn(false); + when(() => nativeMouseEvent.client).thenReturn(Point(1, 2)); + when(() => nativeMouseEvent.page).thenReturn(Point(3, 4)); + when(() => nativeMouseEvent.screen).thenReturn(Point(5, 6)); final syntheticMouseEvent = wrapNativeMouseEvent(nativeMouseEvent); @@ -2015,7 +2015,7 @@ main() { // *See other test with similar note to this one.* test('checks types correctly for Mock objects with `type` mocked', () { final mockEvent = MockSyntheticEvent(); - when(mockEvent.type).thenReturn('click'); + when(() => mockEvent.type).thenReturn('click'); expect(mockEvent.isMouseEvent, isTrue); expect(mockEvent.isKeyboardEvent, false); }); From 57f5437fc0179c3fc98038418b8f048240acded6 Mon Sep 17 00:00:00 2001 From: tusharmathur-wk Date: Thu, 16 May 2024 13:34:08 +0530 Subject: [PATCH 2/3] fixed CI failures and tests --- example/test/react_test_components.dart | 3 +- test/js_builds/shared_tests.dart | 2 +- test/mockito.dart | 16 - test/mockito.mocks.dart | 552 ---------------------- test/react_client/event_helpers_test.dart | 20 +- 5 files changed, 17 insertions(+), 576 deletions(-) delete mode 100644 test/mockito.dart delete mode 100644 test/mockito.mocks.dart diff --git a/example/test/react_test_components.dart b/example/test/react_test_components.dart index 84c179bd..e78ae6ef 100644 --- a/example/test/react_test_components.dart +++ b/example/test/react_test_components.dart @@ -129,7 +129,8 @@ class _ClockComponent extends react.Component { @override render() { - return react.span({'onClick': (event) => print('Hello World!')}, + return react.span( + {'onClick': (event) => print('Hello World!')}, // { 'onClick': (event, [domid = null]) => print("Hello World!") }, ['Seconds elapsed: ', "${state['secondsElapsed']}"]); } diff --git a/test/js_builds/shared_tests.dart b/test/js_builds/shared_tests.dart index 08e5cfa0..5ccab557 100644 --- a/test/js_builds/shared_tests.dart +++ b/test/js_builds/shared_tests.dart @@ -14,7 +14,7 @@ import 'package:react/src/react_client/internal_react_interop.dart'; import 'package:test/test.dart'; void verifyJsFileLoaded(String filename) { - final isLoaded = document.getElementsByTagName('script').any()((script) { + final isLoaded = document.getElementsByTagName('script').any((script) { return Uri.parse((script as ScriptElement).src).pathSegments.last == filename; }); diff --git a/test/mockito.dart b/test/mockito.dart deleted file mode 100644 index 6e84894f..00000000 --- a/test/mockito.dart +++ /dev/null @@ -1,16 +0,0 @@ -// This file generates a mockito.mocks.dart, containing mock classes that -// can be imported by other tests. - -library react.test.mockito_gen_entrypoint; - -import 'dart:html'; -import 'package:mockito/annotations.dart'; -import 'package:react/src/react_client/synthetic_event_wrappers.dart'; - -@GenerateNiceMocks([ - MockSpec(), - MockSpec(), - MockSpec(), - MockSpec(), -]) -main() {} diff --git a/test/mockito.mocks.dart b/test/mockito.mocks.dart deleted file mode 100644 index ad433ed6..00000000 --- a/test/mockito.mocks.dart +++ /dev/null @@ -1,552 +0,0 @@ -// Mocks generated by Mockito 5.4.2 from annotations -// in react/test/mockito.dart. -// Do not manually edit this file. - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:html' as _i2; -import 'dart:math' as _i3; - -import 'package:mocktail/mocktail.dart' as _i1; -import 'package:react/src/react_client/synthetic_event_wrappers.dart' as _i4; - -// ignore_for_file: type=lint -// ignore_for_file: avoid_redundant_argument_values -// ignore_for_file: avoid_setters_without_getters -// ignore_for_file: comment_references -// ignore_for_file: implementation_imports -// ignore_for_file: invalid_use_of_visible_for_testing_member -// ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_parenthesis -// ignore_for_file: camel_case_types -// ignore_for_file: subtype_of_sealed_class - -class _FakeElement_0 extends _i1.SmartFake implements _i2.Element { - _FakeElement_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakePoint_1 extends _i1.SmartFake - implements _i3.Point { - _FakePoint_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeDataTransfer_2 extends _i1.SmartFake implements _i2.DataTransfer { - _FakeDataTransfer_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [KeyboardEvent]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockKeyboardEvent extends _i1.Mock implements _i2.KeyboardEvent { - @override - int get keyCode => (super.noSuchMethod( - Invocation.getter(#keyCode), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - int get charCode => (super.noSuchMethod( - Invocation.getter(#charCode), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - bool get altKey => (super.noSuchMethod( - Invocation.getter(#altKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get ctrlKey => (super.noSuchMethod( - Invocation.getter(#ctrlKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - int get location => (super.noSuchMethod( - Invocation.getter(#location), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - bool get metaKey => (super.noSuchMethod( - Invocation.getter(#metaKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get shiftKey => (super.noSuchMethod( - Invocation.getter(#shiftKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - _i2.Element get matchingTarget => (super.noSuchMethod( - Invocation.getter(#matchingTarget), - returnValue: _FakeElement_0( - this, - Invocation.getter(#matchingTarget), - ), - returnValueForMissingStub: _FakeElement_0( - this, - Invocation.getter(#matchingTarget), - ), - ) as _i2.Element); - - @override - List<_i2.EventTarget> get path => (super.noSuchMethod( - Invocation.getter(#path), - returnValue: <_i2.EventTarget>[], - returnValueForMissingStub: <_i2.EventTarget>[], - ) as List<_i2.EventTarget>); - - @override - bool get defaultPrevented => (super.noSuchMethod( - Invocation.getter(#defaultPrevented), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - int get eventPhase => (super.noSuchMethod( - Invocation.getter(#eventPhase), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - String get type => (super.noSuchMethod( - Invocation.getter(#type), - returnValue: '', - returnValueForMissingStub: '', - ) as String); - - @override - bool getModifierState(String? keyArg) => (super.noSuchMethod( - Invocation.method( - #getModifierState, - [keyArg], - ), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - List<_i2.EventTarget> composedPath() => (super.noSuchMethod( - Invocation.method( - #composedPath, - [], - ), - returnValue: <_i2.EventTarget>[], - returnValueForMissingStub: <_i2.EventTarget>[], - ) as List<_i2.EventTarget>); - - @override - void preventDefault() => super.noSuchMethod( - Invocation.method( - #preventDefault, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void stopImmediatePropagation() => super.noSuchMethod( - Invocation.method( - #stopImmediatePropagation, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void stopPropagation() => super.noSuchMethod( - Invocation.method( - #stopPropagation, - [], - ), - returnValueForMissingStub: null, - ); -} - -/// A class which mocks [DataTransfer]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockDataTransfer extends _i1.Mock implements _i2.DataTransfer { - @override - set dropEffect(String? value) => super.noSuchMethod( - Invocation.setter( - #dropEffect, - value, - ), - returnValueForMissingStub: null, - ); - - @override - set effectAllowed(String? value) => super.noSuchMethod( - Invocation.setter( - #effectAllowed, - value, - ), - returnValueForMissingStub: null, - ); - - @override - void clearData([String? format]) => super.noSuchMethod( - Invocation.method( - #clearData, - [format], - ), - returnValueForMissingStub: null, - ); - - @override - String getData(String? format) => (super.noSuchMethod( - Invocation.method( - #getData, - [format], - ), - returnValue: '', - returnValueForMissingStub: '', - ) as String); - - @override - void setData( - String? format, - String? data, - ) => - super.noSuchMethod( - Invocation.method( - #setData, - [ - format, - data, - ], - ), - returnValueForMissingStub: null, - ); - - @override - void setDragImage( - _i2.Element? image, - int? x, - int? y, - ) => - super.noSuchMethod( - Invocation.method( - #setDragImage, - [ - image, - x, - y, - ], - ), - returnValueForMissingStub: null, - ); -} - -/// A class which mocks [MouseEvent]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMouseEvent extends _i1.Mock implements _i2.MouseEvent { - @override - bool get altKey => (super.noSuchMethod( - Invocation.getter(#altKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - int get button => (super.noSuchMethod( - Invocation.getter(#button), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - bool get ctrlKey => (super.noSuchMethod( - Invocation.getter(#ctrlKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get metaKey => (super.noSuchMethod( - Invocation.getter(#metaKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get shiftKey => (super.noSuchMethod( - Invocation.getter(#shiftKey), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - _i3.Point get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakePoint_1( - this, - Invocation.getter(#client), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Point); - - @override - _i3.Point get movement => (super.noSuchMethod( - Invocation.getter(#movement), - returnValue: _FakePoint_1( - this, - Invocation.getter(#movement), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#movement), - ), - ) as _i3.Point); - - @override - _i3.Point get offset => (super.noSuchMethod( - Invocation.getter(#offset), - returnValue: _FakePoint_1( - this, - Invocation.getter(#offset), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#offset), - ), - ) as _i3.Point); - - @override - _i3.Point get screen => (super.noSuchMethod( - Invocation.getter(#screen), - returnValue: _FakePoint_1( - this, - Invocation.getter(#screen), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#screen), - ), - ) as _i3.Point); - - @override - _i3.Point get layer => (super.noSuchMethod( - Invocation.getter(#layer), - returnValue: _FakePoint_1( - this, - Invocation.getter(#layer), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#layer), - ), - ) as _i3.Point); - - @override - _i3.Point get page => (super.noSuchMethod( - Invocation.getter(#page), - returnValue: _FakePoint_1( - this, - Invocation.getter(#page), - ), - returnValueForMissingStub: _FakePoint_1( - this, - Invocation.getter(#page), - ), - ) as _i3.Point); - - @override - _i2.DataTransfer get dataTransfer => (super.noSuchMethod( - Invocation.getter(#dataTransfer), - returnValue: _FakeDataTransfer_2( - this, - Invocation.getter(#dataTransfer), - ), - returnValueForMissingStub: _FakeDataTransfer_2( - this, - Invocation.getter(#dataTransfer), - ), - ) as _i2.DataTransfer); - - @override - _i2.Element get matchingTarget => (super.noSuchMethod( - Invocation.getter(#matchingTarget), - returnValue: _FakeElement_0( - this, - Invocation.getter(#matchingTarget), - ), - returnValueForMissingStub: _FakeElement_0( - this, - Invocation.getter(#matchingTarget), - ), - ) as _i2.Element); - - @override - List<_i2.EventTarget> get path => (super.noSuchMethod( - Invocation.getter(#path), - returnValue: <_i2.EventTarget>[], - returnValueForMissingStub: <_i2.EventTarget>[], - ) as List<_i2.EventTarget>); - - @override - bool get defaultPrevented => (super.noSuchMethod( - Invocation.getter(#defaultPrevented), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - int get eventPhase => (super.noSuchMethod( - Invocation.getter(#eventPhase), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); - - @override - String get type => (super.noSuchMethod( - Invocation.getter(#type), - returnValue: '', - returnValueForMissingStub: '', - ) as String); - - @override - bool getModifierState(String? keyArg) => (super.noSuchMethod( - Invocation.method( - #getModifierState, - [keyArg], - ), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - List<_i2.EventTarget> composedPath() => (super.noSuchMethod( - Invocation.method( - #composedPath, - [], - ), - returnValue: <_i2.EventTarget>[], - returnValueForMissingStub: <_i2.EventTarget>[], - ) as List<_i2.EventTarget>); - - @override - void preventDefault() => super.noSuchMethod( - Invocation.method( - #preventDefault, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void stopImmediatePropagation() => super.noSuchMethod( - Invocation.method( - #stopImmediatePropagation, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void stopPropagation() => super.noSuchMethod( - Invocation.method( - #stopPropagation, - [], - ), - returnValueForMissingStub: null, - ); -} - -/// A class which mocks [SyntheticEvent]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockSyntheticEvent extends _i1.Mock implements _i4.SyntheticEvent { - @override - bool get bubbles => (super.noSuchMethod( - Invocation.getter(#bubbles), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get cancelable => (super.noSuchMethod( - Invocation.getter(#cancelable), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - bool get defaultPrevented => (super.noSuchMethod( - Invocation.getter(#defaultPrevented), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - num get eventPhase => (super.noSuchMethod( - Invocation.getter(#eventPhase), - returnValue: 0, - returnValueForMissingStub: 0, - ) as num); - - @override - bool get isTrusted => (super.noSuchMethod( - Invocation.getter(#isTrusted), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); - - @override - num get timeStamp => (super.noSuchMethod( - Invocation.getter(#timeStamp), - returnValue: 0, - returnValueForMissingStub: 0, - ) as num); - - @override - String get type => (super.noSuchMethod( - Invocation.getter(#type), - returnValue: '', - returnValueForMissingStub: '', - ) as String); - - @override - void preventDefault() => super.noSuchMethod( - Invocation.method( - #preventDefault, - [], - ), - returnValueForMissingStub: null, - ); -} diff --git a/test/react_client/event_helpers_test.dart b/test/react_client/event_helpers_test.dart index 7ce8dcf0..57a49d77 100644 --- a/test/react_client/event_helpers_test.dart +++ b/test/react_client/event_helpers_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_implementing_value_types + @TestOn('browser') library react.event_helpers_test; @@ -11,8 +13,6 @@ import 'package:react/react_test_utils.dart'; import 'package:test/test.dart'; import 'package:mocktail/mocktail.dart'; -import '../mockito.mocks.dart'; - main() { group('Synthetic event helpers', () { const testString = 'test'; @@ -110,8 +110,8 @@ main() { when(() => nativeKeyboardEvent.cancelable).thenReturn(true); when(() => nativeKeyboardEvent.currentTarget).thenReturn(currentTarget); when(() => nativeKeyboardEvent.defaultPrevented).thenReturn(false); - when(() => nativeKeyboardEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); - when(() => nativeKeyboardEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); + when(nativeKeyboardEvent.preventDefault).thenAnswer((_) => calls.add('preventDefault')); + when(nativeKeyboardEvent.stopPropagation).thenAnswer((_) => calls.add('stopPropagation')); when(() => nativeKeyboardEvent.eventPhase).thenReturn(0); when(() => nativeKeyboardEvent.target).thenReturn(target); when(() => nativeKeyboardEvent.timeStamp).thenReturn(0); @@ -173,8 +173,8 @@ main() { when(() => nativeMouseEvent.cancelable).thenReturn(true); when(() => nativeMouseEvent.currentTarget).thenReturn(currentTarget); when(() => nativeMouseEvent.defaultPrevented).thenReturn(false); - when(() => nativeMouseEvent.preventDefault()).thenAnswer((_) => calls.add('preventDefault')); - when(() => nativeMouseEvent.stopPropagation()).thenAnswer((_) => calls.add('stopPropagation')); + when(nativeMouseEvent.preventDefault).thenAnswer((_) => calls.add('preventDefault')); + when(nativeMouseEvent.stopPropagation).thenAnswer((_) => calls.add('stopPropagation')); when(() => nativeMouseEvent.eventPhase).thenReturn(0); when(() => nativeMouseEvent.target).thenReturn(target); when(() => nativeMouseEvent.timeStamp).thenReturn(0); @@ -2107,6 +2107,14 @@ main() { }); } +class MockDataTransfer extends Mock implements DataTransfer {} + +class MockKeyboardEvent extends Mock implements KeyboardEvent {} + +class MockMouseEvent extends Mock implements MouseEvent {} + +class MockSyntheticEvent extends Mock implements SyntheticEvent {} + enum SyntheticEventType { syntheticClipboardEvent, syntheticKeyboardEvent, From fa413fd1667c087f1fe3fd79f9200a1392e01b48 Mon Sep 17 00:00:00 2001 From: tusharmathur-wk Date: Thu, 16 May 2024 13:41:42 +0530 Subject: [PATCH 3/3] run format --- example/test/react_test_components.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/test/react_test_components.dart b/example/test/react_test_components.dart index e78ae6ef..84c179bd 100644 --- a/example/test/react_test_components.dart +++ b/example/test/react_test_components.dart @@ -129,8 +129,7 @@ class _ClockComponent extends react.Component { @override render() { - return react.span( - {'onClick': (event) => print('Hello World!')}, + return react.span({'onClick': (event) => print('Hello World!')}, // { 'onClick': (event, [domid = null]) => print("Hello World!") }, ['Seconds elapsed: ', "${state['secondsElapsed']}"]); }