Skip to content

Commit

Permalink
Adding tests. #1
Browse files Browse the repository at this point in the history
  • Loading branch information
caduandrade committed Sep 28, 2023
1 parent 823181c commit d50df8f
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/layout_stringify_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import 'package:flutter_test/flutter_test.dart';
import 'exceptions.dart';
import 'utils.dart';

class IdClass {
IdClass(this.value);

final String value;
}

void main() {
final LayoutParser parser = LayoutParser();

Expand Down Expand Up @@ -126,5 +132,56 @@ void main() {
valueToString: LayoutParser.defaultValueToString),
'3;id;;2;f;;6;value;;T;;F');
});
test('stringifyItem - idToString', () {
DockingItem itemA = DockingItem(id: 1.2, widget: Container());
DockingItem itemB = DockingItem(id: null, widget: Container());
DockingItem itemC = DockingItem(widget: Container());
DockingItem itemD =
DockingItem(id: IdClass('id-class'), widget: Container());

DockingRow row = DockingRow([itemA, itemB, itemC, itemD]);

DockingLayout(root: row);

expect(
parser.stringifyItem(
item: itemA,
idToString: (id) => (id + 1).toString(),
valueToString: LayoutParser.defaultValueToString),
'3;2.2;0;;0;;T;;F');
expect(
parser.stringifyItem(
item: itemB,
idToString: (id) {
if (id == null) {
return 'X';
}
return id.toString();
},
valueToString: LayoutParser.defaultValueToString),
'1;X;0;;0;;T;;F');
expect(
parser.stringifyItem(
item: itemC,
idToString: (id) {
if (id == null) {
return 'Y';
}
return id.toString();
},
valueToString: LayoutParser.defaultValueToString),
'1;Y;0;;0;;T;;F');
expect(
parser.stringifyItem(
item: itemD,
idToString: (id) {
if (id is IdClass) {
return id.value;
}
return '';
},
valueToString: LayoutParser.defaultValueToString),
'8;id-class;0;;0;;T;;F');
});
});
}

0 comments on commit d50df8f

Please sign in to comment.