|
3 | 3 | // BSD-style license that can be found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import 'package:analyzer/file_system/file_system.dart';
|
| 6 | +import 'package:analyzer/file_system/memory_file_system.dart'; |
6 | 7 | import 'package:dartdoc/src/dartdoc_options.dart';
|
7 | 8 | import 'package:dartdoc/src/io_utils.dart';
|
8 | 9 | import 'package:dartdoc/src/package_meta.dart';
|
@@ -758,4 +759,31 @@ dartdoc:
|
758 | 759 | equals('parent'));
|
759 | 760 | });
|
760 | 761 | });
|
| 762 | + |
| 763 | + group('CategoryConfiguration', () { |
| 764 | + const configData = ''' |
| 765 | +CategoryOne: |
| 766 | + external: |
| 767 | + - name: 'package:web' |
| 768 | + url: https://pub.dev/documentation/web/latest/ |
| 769 | + docs: Lorem ipsum. |
| 770 | +'''; |
| 771 | + |
| 772 | + test('parses external items', () { |
| 773 | + final resourceProvider = MemoryResourceProvider(); |
| 774 | + final yamlMap = loadYaml(configData) as YamlMap; |
| 775 | + final result = |
| 776 | + CategoryConfiguration.fromYamlMap(yamlMap, '', resourceProvider); |
| 777 | + expect(result.categoryDefinitions, hasLength(1)); |
| 778 | + |
| 779 | + final name = result.categoryDefinitions.keys.first; |
| 780 | + final definition = result.categoryDefinitions[name]!; |
| 781 | + expect(name, 'CategoryOne'); |
| 782 | + expect(definition.externalItems, hasLength(1)); |
| 783 | + |
| 784 | + final item = definition.externalItems.first; |
| 785 | + expect(item.name, 'package:web'); |
| 786 | + expect(item.url, 'https://pub.dev/documentation/web/latest/'); |
| 787 | + }); |
| 788 | + }); |
761 | 789 | }
|
0 commit comments