@@ -49,6 +49,24 @@ void main() {
49
49
fail ('should have successfully loaded json spec' );
50
50
}
51
51
});
52
+ test ('yaml (requires transformation)' , () async {
53
+ try {
54
+ final loaded =
55
+ await loadSpec (specPath: supportedExtensions['yaml' ]! );
56
+ expect (loaded, jsonSpecFile);
57
+ } catch (_, __) {
58
+ fail ('Should successfully convert yaml to Map' );
59
+ }
60
+ });
61
+ test ('yml (requires transformation)' , () async {
62
+ try {
63
+ final loaded =
64
+ await loadSpec (specPath: supportedExtensions['yml' ]! );
65
+ expect (loaded, jsonSpecFile);
66
+ } catch (_, __) {
67
+ fail ('Should successfully convert yml to Map' );
68
+ }
69
+ });
52
70
});
53
71
});
54
72
group ('verifies dirty status' , () {
@@ -127,37 +145,64 @@ void main() {
127
145
});
128
146
});
129
147
group ('transforms yaml to dart map' , () {
130
- test ('returns a map from yaml' , () async {
131
- expect (await loadSpec (specPath: supportedExtensions['yaml' ]! ),
132
- jsonSpecFile);
133
- });
134
- test ('returns a map from yml' , () async {
135
- expect (await loadSpec (specPath: supportedExtensions['yml' ]! ),
136
- jsonSpecFile);
137
- });
138
148
test ('converts scalars' , () {
139
149
expect (convertYamlMapToDartMap (yamlMap: YamlMap .wrap ({'scalar' : 5 })),
140
150
{'scalar' : 5 });
141
151
});
142
- test ('converts list' , () {
143
- final listContent = [
144
- 1 ,
145
- 2 ,
146
- 3 ,
147
- 4 ,
148
- YamlMap .wrap (< String , dynamic > {'entry' : 'value' })
149
- ];
150
- final listContentExpected = [
151
- 1 ,
152
- 2 ,
153
- 3 ,
154
- 4 ,
155
- < String , dynamic > {'entry' : 'value' }
156
- ];
152
+ group ('converts lists' , () {
153
+ test ('with YamlMaps' , () {
154
+ final listContent = [
155
+ 1 ,
156
+ 2 ,
157
+ 3 ,
158
+ 4 ,
159
+ YamlMap .wrap (< String , dynamic > {'entry' : 'value' })
160
+ ];
161
+ final listContentExpected = [
162
+ 1 ,
163
+ 2 ,
164
+ 3 ,
165
+ 4 ,
166
+ < String , dynamic > {'entry' : 'value' }
167
+ ];
168
+ expect (
169
+ convertYamlListToDartList (yamlList: YamlList .wrap (listContent)),
170
+ listContentExpected);
171
+ });
172
+ test ('with nested lists' , () {
173
+ final listContent = [
174
+ 1 ,
175
+ 2 ,
176
+ 3 ,
177
+ 4 ,
178
+ YamlList .wrap (
179
+ ["one" , "two" , "three" ],
180
+ )
181
+ ];
182
+ final listContentExpected = [
183
+ 1 ,
184
+ 2 ,
185
+ 3 ,
186
+ 4 ,
187
+ ["one" , "two" , "three" ],
188
+ ];
189
+ expect (
190
+ convertYamlListToDartList (yamlList: YamlList .wrap (listContent)),
191
+ listContentExpected);
192
+ });
193
+ });
194
+ test ('converts submap to map' , () {
195
+ final expectedMap = < String , dynamic > {
196
+ 'mapWithSubMap' : {
197
+ 'subMap' : {'scalar' : 5 , 'meh' : 'value' },
198
+ }
199
+ };
157
200
expect (
158
201
convertYamlMapToDartMap (
159
- yamlMap: YamlMap .wrap ({'scalar' : YamlList .wrap (listContent)})),
160
- {'scalar' : listContentExpected});
202
+ yamlMap: YamlMap .wrap ({
203
+ 'mapWithSubMap' : YamlMap .wrap (expectedMap['mapWithSubMap' ])
204
+ })),
205
+ expectedMap);
161
206
});
162
207
});
163
208
});
0 commit comments