Skip to content

Commit

Permalink
Fixes all unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FilledStacks committed Jan 30, 2024
1 parent 2cac3bb commit f01564e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ void main() {
)
]);
expect(
result[1].renderPosition,
WidgetPosition(
x: 2,
y: 2,
capturedDeviceHeight: 0,
capturedDeviceWidth: 0,
));
result[1].renderPosition,
WidgetPosition(
x: 2,
y: 2,
capturedDeviceHeight: 0,
capturedDeviceWidth: 0,
orientation: Orientation.landscape,
active: true,
),
);
});
});
});
Expand Down
15 changes: 13 additions & 2 deletions packages/testsweets/test/helpers/test_consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ final kGeneralInteractionWithZeroOffset = Interaction(
originalViewName: 'originalViewName',
name: 'widgetName',
widgetType: WidgetType.general,
widgetPositions: [WidgetPosition.empty()]);
widgetPositions: [
WidgetPosition.empty().copyWith(
active: true,
)
]);

final kGeneralInteraction = Interaction(
originalViewName: '/',
Expand Down Expand Up @@ -123,6 +127,7 @@ final kScrollableInteraction = Interaction(
y: 20,
capturedDeviceWidth: 0,
capturedDeviceHeight: 0,
active: true,
)
],
widgetType: WidgetType.scrollable,
Expand All @@ -138,6 +143,7 @@ final kScrollableInteraction2 = Interaction(
y: 25,
capturedDeviceWidth: 0,
capturedDeviceHeight: 0,
active: true,
)
],
widgetType: WidgetType.scrollable,
Expand Down Expand Up @@ -166,7 +172,12 @@ final kTopLeftVerticalScrollableDescription = ScrollableDescription(
axis: Axis.vertical,
maxScrollExtentByPixels: 0,
scrollExtentByPixels: 100,
rect: SerializableRect.fromPoints(Offset(0, 0), Offset(22, 22)));
rect: SerializableRect.fromPoints(
Offset(0, 0),
Offset(
22,
22,
)));
final kFullScreenVerticalScrollableDescription = ScrollableDescription(
axis: Axis.vertical,
maxScrollExtentByPixels: 2000,
Expand Down
32 changes: 15 additions & 17 deletions packages/testsweets/test/services/scroll_appliance_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:testsweets/src/services/scroll_appliance.dart';
import 'package:testsweets/testsweets.dart';
Expand Down Expand Up @@ -130,24 +131,21 @@ void main() {
expect(biggestScroll, kFullScreenVerticalScrollableDescription);
});

test('''
When moving a touchable that have one externalities from
the top of a list to a normal canvas,
Should remove its externalities''', () {
test(
'When moving a touchable that have one externalities from the top of a list to a normal canvas, Should remove its externalities',
() {
final service = ScrollAppliance();
final touchableInteractionWithOneExternalities =
kTouchableInteraction.copyWith(
// Changed its position
position: WidgetPosition(
x: 400,
y: 400,
capturedDeviceHeight: 0,
capturedDeviceWidth: 0,
),

// This list captured before changing the position
externalities: {kTopLeftVerticalScrollableDescription},
);
final touchableInteractionWithOneExternalities = kTouchableInteraction
.updatePosition(
x: 400,
y: 400,
currentWidth: 0,
currentHeight: 0,
orientation: Orientation.portrait,
)
.copyWith(
// This list captured before changing the position
externalities: {kTopLeftVerticalScrollableDescription});

final result = service.applyScrollableOnInteraction(
[kTopLeftVerticalScrollableDescription],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ When capture a new intercation, Should sync with any scrollable underneath it ''

expect(model.captureState, CaptureWidgetState.idle);
});
test('''When in quickPositionEdit mode and user trigger onLongPressUp
without changing the interaction position,
Should call updateWidgetDescription from WidgetCaptureService
with the same interaction without changing its position''', () async {
test(
'When in quickPositionEdit mode and user trigger onLongPressUp without changing the interaction position, Should call updateWidgetDescription from WidgetCaptureService with the same interaction without changing its position',
() async {
final service = getAndRegisterWidgetCaptureService();

final model = _getViewModel();
Expand All @@ -141,10 +140,9 @@ When capture a new intercation, Should sync with any scrollable underneath it ''
));
});

test('''When in quickPositionEdit mode and user trigger onLongPressUp
while changeing the widget position to new place,
Should call updateWidgetDescription from WidgetCaptureService
with the interaction new position''', () async {
test(
'When in quickPositionEdit mode and user trigger onLongPressUp while changeing the widget position to new place,Should call updateWidgetDescription from WidgetCaptureService with the interaction new position',
() async {
final service = getAndRegisterWidgetCaptureService();

final model = _getViewModel();
Expand All @@ -160,11 +158,12 @@ When capture a new intercation, Should sync with any scrollable underneath it ''

await model.onLongPressUp();

final updatedInteraction = kGeneralInteraction.copyWith(
position: kGeneralInteraction.renderPosition.copyWith(
x: 33.0,
y: 33.0,
),
final updatedInteraction = kGeneralInteraction.updatePosition(
x: 33,
y: 33,
currentWidth: 0,
currentHeight: 0,
orientation: Orientation.portrait,
);

verify(service.updateInteractionInDatabase(
Expand Down

0 comments on commit f01564e

Please sign in to comment.