-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(search_condition): ♻️ move
highlightedRange
as method (#51)
* refactor(search_condition): ♻️ move `highlightedRange` as method * docs(search_condition): 📖 add more examples for `highlightedRange` * test(main): 🧪 add `search_condition_test`
- Loading branch information
1 parent
917c115
commit 8707377
Showing
4 changed files
with
103 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import 'model/definition_entry_sense_test.dart' as definition_entry_sense_test; | ||
import 'model/gender_test.dart' as gender_test; | ||
import 'model/scope_test.dart' as scope_test; | ||
import 'model/search_condition_test.dart' as search_condition_test; | ||
|
||
void main() { | ||
definition_entry_sense_test.main(); | ||
gender_test.main(); | ||
scope_test.main(); | ||
search_condition_test.main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:el_meu_diec/model.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('SearchCondition', () { | ||
group('.highlightedRange()', () { | ||
test('should return the highlighted range in word from query', () { | ||
expect( | ||
SearchCondition.coincident.highlightedRange('dart', 'a'), | ||
const (0, 4), | ||
); | ||
|
||
expect( | ||
SearchCondition.startingWith.highlightedRange('dart', 'd'), | ||
const (0, 1), | ||
); | ||
expect( | ||
SearchCondition.startingWith.highlightedRange('alçària', 'alça'), | ||
const (0, 4), | ||
); | ||
|
||
expect( | ||
SearchCondition.endingIn.highlightedRange('dart', 'rt'), | ||
const (2, 4), | ||
); | ||
expect( | ||
SearchCondition.endingIn.highlightedRange('dart2', 't'), | ||
const (3, 4), | ||
); | ||
expect( | ||
SearchCondition.endingIn.highlightedRange('fabària', 'aria'), | ||
const (3, 7), | ||
); | ||
|
||
expect( | ||
SearchCondition.inAnyPosition.highlightedRange('dart', 'a'), | ||
const (1, 2), | ||
); | ||
}); | ||
|
||
test('should return null when no range to highlight is found', () { | ||
expect( | ||
SearchCondition.startingWith.highlightedRange('dart', 'c'), | ||
isNull, | ||
); | ||
expect( | ||
SearchCondition.notStartingWith.highlightedRange('dart', 'f'), | ||
isNull, | ||
); | ||
expect( | ||
SearchCondition.notEndingIn.highlightedRange('dart', 'f'), | ||
isNull, | ||
); | ||
expect( | ||
SearchCondition.doesNotContain.highlightedRange('dart', 'f'), | ||
isNull, | ||
); | ||
}); | ||
}); | ||
}); | ||
} |