|
| 1 | +import 'package:flutterflow_cli/src/flutterflow_ignore.dart'; |
| 2 | + |
| 3 | +import 'package:test/test.dart'; |
| 4 | + |
| 5 | +void main() { |
| 6 | + test('does not match when file is not found', () { |
| 7 | + var ignore = FlutterFlowIgnore(path: '/this/path/is/wrong/'); |
| 8 | + |
| 9 | + expect(ignore.matches('file'), false); |
| 10 | + }); |
| 11 | + |
| 12 | + test('basic globbing syntax', () { |
| 13 | + var ignore = FlutterFlowIgnore(path: 'test/fixtures'); |
| 14 | + |
| 15 | + expect(ignore.matches('file'), true); |
| 16 | + expect(ignore.matches('dir/foo'), true); |
| 17 | + expect(ignore.matches('dir/bar'), true); |
| 18 | + expect(ignore.matches('this/file/exactly'), true); |
| 19 | + |
| 20 | + expect(ignore.matches('this/directory/matches'), true); |
| 21 | + expect(ignore.matches('this/directory/also/matches'), true); |
| 22 | + |
| 23 | + expect(ignore.matches('dir_recursive/foo/file'), true); |
| 24 | + expect(ignore.matches('dir_recursive/foo/bar/file'), true); |
| 25 | + expect(ignore.matches('dir_recursive/foo/bar/foo/file'), true); |
| 26 | + |
| 27 | + expect(ignore.matches('dir_recursive_implicit/foo/file'), true); |
| 28 | + expect(ignore.matches('dir_recursive_implicit/foo/bar/file'), true); |
| 29 | + expect(ignore.matches('dir_recursive_implicit/foo/bar/foo/file'), true); |
| 30 | + |
| 31 | + expect(ignore.matches('this/file'), false); |
| 32 | + expect(ignore.matches('this/file/not_really'), false); |
| 33 | + expect(ignore.matches('file/not_a_directory'), false); |
| 34 | + expect(ignore.matches('file_not_found'), false); |
| 35 | + expect(ignore.matches('dir_not_found/foo'), false); |
| 36 | + expect(ignore.matches('dir_not_found/bar'), false); |
| 37 | + expect(ignore.matches('this/directory'), false); |
| 38 | + |
| 39 | + expect(ignore.matches('dir_recursive/foo/file_not_found'), false); |
| 40 | + expect(ignore.matches('dir_recursive/foo/bar/file_not_found'), false); |
| 41 | + expect(ignore.matches('dir_recursive/foo/bar/foo/file_not_found'), false); |
| 42 | + }); |
| 43 | + |
| 44 | + test('comments are ignored', () { |
| 45 | + var ignore = FlutterFlowIgnore(path: 'test/fixtures'); |
| 46 | + |
| 47 | + expect(ignore.matches('#comment'), false); |
| 48 | + expect(ignore.matches('#another_comment'), false); |
| 49 | + }); |
| 50 | + |
| 51 | + test('does not match empty paths', () { |
| 52 | + var ignore = FlutterFlowIgnore(path: 'test/fixtures'); |
| 53 | + |
| 54 | + expect(ignore.matches(''), false); |
| 55 | + }); |
| 56 | + |
| 57 | + test('ignores leading and trailing spaces', () { |
| 58 | + var ignore = FlutterFlowIgnore(path: 'test/fixtures'); |
| 59 | + |
| 60 | + expect(ignore.matches('LEADING_SPACES.md'), true); |
| 61 | + expect(ignore.matches('TRAILING_SPACES.md'), true); |
| 62 | + expect(ignore.matches('LEADING_AND_TRAILING_SPACES.md'), true); |
| 63 | + }); |
| 64 | +} |
0 commit comments