Skip to content

Commit 5dab948

Browse files
authored
Merge pull request #74 from olexale/bugfix/comments_fix
Fix #73
2 parents 4b86c26 + bfefe90 commit 5dab948

3 files changed

Lines changed: 89 additions & 1 deletion

File tree

lib/src/feature_file.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ class FeatureFile {
106106
).toList(growable: false);
107107

108108
final headers = lines
109-
.where((value) => value.type == LineType.unknown)
110109
.takeWhile((value) => value.type != LineType.feature)
110+
.where((value) => value.type == LineType.unknown)
111111
.foldIndexed(
112112
// this removes empty line dupicates
113113
<BddLine>[],

test/comment_test.dart

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import 'package:bdd_widget_test/src/feature_file.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
4+
void main() {
5+
test('Comments above features copy-paste into the target file', () {
6+
const featureFile = '''
7+
// This is a comment
8+
9+
Feature: Testing feature
10+
Scenario: Testing scenario
11+
Given the app is running
12+
''';
13+
14+
const expectedFeatureDart = '''
15+
// GENERATED CODE - DO NOT MODIFY BY HAND
16+
// ignore_for_file: unused_import, directives_ordering
17+
18+
// This is a comment
19+
20+
import 'package:flutter/material.dart';
21+
import 'package:flutter_test/flutter_test.dart';
22+
23+
import './step/the_app_is_running.dart';
24+
25+
void main() {
26+
group(\'\'\'Testing feature\'\'\', () {
27+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
28+
await theAppIsRunning(tester);
29+
});
30+
});
31+
}
32+
''';
33+
34+
final feature = FeatureFile(
35+
featureDir: 'test.feature',
36+
package: 'test',
37+
input: featureFile,
38+
);
39+
expect(feature.dartContent, expectedFeatureDart);
40+
});
41+
42+
test('Comments after first feature are ignored', () {
43+
const featureFile = '''
44+
Feature: Testing feature
45+
This is a comment
46+
Scenario: Testing scenario
47+
Given the app is running
48+
49+
This is another comment
50+
Feature: Testing feature 2
51+
This is a comment
52+
Scenario: Testing scenario
53+
Given the app is running
54+
This is a comment too
55+
''';
56+
57+
const expectedFeatureDart = '''
58+
// GENERATED CODE - DO NOT MODIFY BY HAND
59+
// ignore_for_file: unused_import, directives_ordering
60+
61+
import 'package:flutter/material.dart';
62+
import 'package:flutter_test/flutter_test.dart';
63+
64+
import './step/the_app_is_running.dart';
65+
66+
void main() {
67+
group(\'\'\'Testing feature\'\'\', () {
68+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
69+
await theAppIsRunning(tester);
70+
});
71+
});
72+
group(\'\'\'Testing feature 2\'\'\', () {
73+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
74+
await theAppIsRunning(tester);
75+
});
76+
});
77+
}
78+
''';
79+
80+
final feature = FeatureFile(
81+
featureDir: 'test.feature',
82+
package: 'test',
83+
input: featureFile,
84+
);
85+
expect(feature.dartContent, expectedFeatureDart);
86+
});
87+
}

test/tags_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void main() {
4242
const featureFile = '''
4343
@integration
4444
import 'package:my_package/my_package.dart';
45+
4546
@slow
4647
Feature: Testing feature
4748
Scenario: Testing scenario

0 commit comments

Comments
 (0)