Skip to content

Commit a33eb2c

Browse files
committed
✅ Test SuffixRules.ruleMap
1 parent 9b6d6cb commit a33eb2c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/suffix_rules_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,36 @@ void main() {
177177
});
178178
});
179179

180+
group('ruleMap_', () {
181+
tearDown(() => SuffixRules.dispose());
182+
183+
test('afterInitialising_returnMap', () {
184+
SuffixRules.initFromList(['br', 'br.nom']);
185+
expect(SuffixRules.ruleMap, isNotNull);
186+
expect(SuffixRules.ruleMap, hasLength(2));
187+
expect(SuffixRules.ruleMap, containsPair('br', [Rule('br')]));
188+
});
189+
190+
test('beforeInitialising_returnNull', () {
191+
expect(SuffixRules.ruleMap, isNull);
192+
});
193+
194+
test('multipleRulesFromSameTld_combineIntoSameList', () {
195+
SuffixRules.initFromList(['br', 'nom.br', 'nom.mer.br']);
196+
expect(SuffixRules.ruleMap, isNotNull);
197+
expect(SuffixRules.ruleMap, hasLength(1));
198+
expect(SuffixRules.ruleMap,
199+
containsPair('br', [Rule('br'), Rule('nom.br'), Rule('nom.mer.br')]));
200+
});
201+
202+
test('modifyMap_exception', () {
203+
SuffixRules.initFromList(['br', 'nom.br']);
204+
expect(() => SuffixRules.ruleMap['rb'] = [Rule('rb')],
205+
throwsUnsupportedError);
206+
expect(() => SuffixRules.ruleMap.remove('br'), throwsUnsupportedError);
207+
});
208+
});
209+
180210
group('initFromList_', () {
181211
test('listWithComments_commentsRemoved', () {
182212
var lines = <String>['br', '//comment', 'nom.br'];

0 commit comments

Comments
 (0)