Skip to content

Commit

Permalink
Fix data table parser
Browse files Browse the repository at this point in the history
  • Loading branch information
olexale committed Feb 17, 2024
1 parent 9228996 commit 7f3a38d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/src/data_table_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ Iterable<BddLine> replaceDataTables(List<BddLine> lines) sync* {
lines[index].type == LineType.dataTableStep;
final isNextLineTable = isTable(lines: lines, index: index + 1);
if (isStep && isNextLineTable) {
if (!hasExamplesFormat(bddLine: lines[index])) {
yield* _createCucumberDataTable(lines: lines, index: index);
} else {
yield* _createDataTableFromExamples(lines: lines, index: index);
final table = !hasExamplesFormat(bddLine: lines[index])
? _createCucumberDataTable(lines: lines, index: index)
: _createDataTableFromExamples(lines: lines, index: index);
yield* table;
// skip the parsed table
while (isTable(lines: lines, index: index + 1)) {
index++;
}
} else {
yield lines[index];
Expand Down
10 changes: 8 additions & 2 deletions test/data_tables_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,12 @@ void main() {
Feature: Testing feature
Background:
Given the following songs
Given I wait
And the following songs
| artist | title |
| 'The Beatles' | 'Let It Be' |
| 'Camel' | 'Slow yourself down' |
And I wait
Scenario: Testing scenario
Given I wait
Expand All @@ -344,14 +346,16 @@ import 'package:bdd_widget_test/data_table.dart' as bdd;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import './step/the_following_songs.dart';
import './step/i_wait.dart';
import './step/the_following_songs.dart';
import './step/the_following_users_exist.dart';
void main() {
group(\'\'\'Testing feature\'\'\', () {
Future<void> bddSetUp(WidgetTester tester) async {
await iWait(tester);
await theFollowingSongs(tester, const bdd.DataTable([[artist, title], ['The Beatles', 'Let It Be'], ['Camel', 'Slow yourself down']]));
await iWait(tester);
}
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
await bddSetUp(tester);
Expand Down Expand Up @@ -382,6 +386,7 @@ Feature: Testing feature
| name | twitter |
| 'Oleksandr' | '@olexale' |
| 'Flutter' | '@FlutterDev' |
And I wait
Scenario: Testing scenario
Given the following songs
Expand Down Expand Up @@ -409,6 +414,7 @@ void main() {
await iWait(tester);
await theFollowingUsersExist(tester, 'Oleksandr', '@olexale');
await theFollowingUsersExist(tester, 'Flutter', '@FlutterDev');
await iWait(tester);
}
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
try {
Expand Down

0 comments on commit 7f3a38d

Please sign in to comment.