|
| 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 | +} |
0 commit comments