@@ -5,201 +5,195 @@ import 'package:nextcloud_test/nextcloud_test.dart';
5
5
import 'package:test/test.dart' ;
6
6
7
7
void main () {
8
- presets (
9
- 'cookbook' ,
10
- 'cookbook' ,
11
- (tester) {
12
- group ('CookbookVersionCheck' , () {
13
- test ('Is supported' , () async {
14
- final response = await tester.client.cookbook.getVersionCheck ();
15
-
16
- expect (response.isSupported, isTrue);
17
- });
8
+ presets ('cookbook' , 'cookbook' , (tester) {
9
+ group ('CookbookVersionCheck' , () {
10
+ test ('Is supported' , () async {
11
+ final response = await tester.client.cookbook.getVersionCheck ();
12
+
13
+ expect (response.isSupported, isTrue);
18
14
});
15
+ });
19
16
20
- group ('categories' , () {
21
- test ('listCategories' , () async {
22
- final response = await tester.client.cookbook.categories.listCategories ();
17
+ group ('categories' , () {
18
+ test ('listCategories' , () async {
19
+ final response = await tester.client.cookbook.categories.listCategories ();
23
20
24
- expect (response.body, hasLength (7 ));
25
- });
21
+ expect (response.body, hasLength (7 ));
22
+ });
23
+
24
+ test ('recipesInCategory' , () async {
25
+ final response = await tester.client.cookbook.categories.recipesInCategory (category: 'Soup' );
26
26
27
- test ( 'recipesInCategory' , () async {
28
- final response = await tester.client.cookbook.categories. recipesInCategory (category : 'Soup' );
27
+ expect (response.body, hasLength ( 2 ));
28
+ } );
29
29
30
- expect (response.body, hasLength (2 ));
30
+ test ('renameCategory' , () async {
31
+ final recipe = cookbook.RecipeBuilder ()
32
+ ..name = 'My super cool recipe'
33
+ ..dateCreated = DateTime .utc (2023 ).toIso8601String ()
34
+ ..recipeCategory = 'Test' ;
35
+ final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
36
+ addTearDown (() async {
37
+ closeFixture ();
38
+ await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
31
39
});
40
+ expect (createResponse.body, isNotNull);
32
41
33
- test ('renameCategory' , () async {
34
- final recipe = cookbook.RecipeBuilder ()
35
- ..name = 'My super cool recipe'
36
- ..dateCreated = DateTime .utc (2023 ).toIso8601String ()
37
- ..recipeCategory = 'Test' ;
38
- final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
39
- addTearDown (() async {
40
- closeFixture ();
41
- await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
42
- });
43
- expect (createResponse.body, isNotNull);
44
-
45
- final request = cookbook.RenameCategoryRequestApplicationJsonBuilder ()..name = 'Delicious Soup' ;
46
-
47
- final response = await tester.client.cookbook.categories.renameCategory (
48
- category: 'Test' ,
49
- $body: request.build (),
50
- );
42
+ final request = cookbook.RenameCategoryRequestApplicationJsonBuilder ()..name = 'Delicious Soup' ;
51
43
52
- expect (response.body, request.name);
53
- });
44
+ final response = await tester.client.cookbook.categories.renameCategory (
45
+ category: 'Test' ,
46
+ $body: request.build (),
47
+ );
48
+
49
+ expect (response.body, request.name);
50
+ });
51
+ });
52
+
53
+ group ('misc' , () {
54
+ final expectedConfig = cookbook.ConfigBuilder ()
55
+ ..folder = '/Recipes'
56
+ ..updateInterval = 5
57
+ ..printImage = true
58
+ ..visibleInfoBlocks.update (
59
+ (b) => b
60
+ ..preparationTime = true
61
+ ..cookingTime = true
62
+ ..totalTime = true
63
+ ..nutritionInformation = true
64
+ ..tools = true ,
65
+ );
66
+
67
+ test ('getConfig' , () async {
68
+ final response = await tester.client.cookbook.misc.getConfig ();
69
+
70
+ expect (response.body, equalsBuilt (expectedConfig.build ()));
54
71
});
55
72
56
- group ('misc' , () {
57
- final expectedConfig = cookbook.ConfigBuilder ()
58
- ..folder = '/Recipes'
59
- ..updateInterval = 5
60
- ..printImage = true
61
- ..visibleInfoBlocks.update (
62
- (b) => b
63
- ..preparationTime = true
64
- ..cookingTime = true
65
- ..totalTime = true
66
- ..nutritionInformation = true
67
- ..tools = true ,
68
- );
73
+ test ('reindex' , () async {
74
+ final response = await tester.client.cookbook.misc.reindex ();
69
75
70
- test ( 'getConfig' , () async {
71
- final response = await tester.client.cookbook.misc. getConfig ( );
76
+ expect (response.body, 'Search index rebuilt successfully' );
77
+ } );
72
78
73
- expect (response.body, equalsBuilt (expectedConfig.build ()));
79
+ test ('setConfig' , () async {
80
+ addTearDown (() async {
81
+ closeFixture ();
82
+ await tester.client.cookbook.misc.setConfig ($body: expectedConfig.build ());
74
83
});
75
84
76
- test ( 'reindex' , () async {
77
- final response = await tester.client.cookbook.misc.reindex ( );
85
+ final config = cookbook. ConfigBuilder ()..folder = '/' ;
86
+ final response = await tester.client.cookbook.misc.setConfig ($body : config. build () );
78
87
79
- expect (response.body, 'Search index rebuilt successfully ' );
80
- });
88
+ expect (response.body, 'OK ' );
89
+ });
81
90
82
- test ('setConfig' , () async {
83
- addTearDown (() async {
84
- closeFixture ();
85
- await tester.client.cookbook.misc.setConfig ($body: expectedConfig.build ());
86
- });
91
+ test ('version' , () async {
92
+ final response = await tester.client.cookbook.misc.version ();
87
93
88
- final config = cookbook.ConfigBuilder ()..folder = '/' ;
89
- final response = await tester.client.cookbook.misc.setConfig ($body: config.build ());
94
+ final cookbookVersion = response.body.cookbookVersion! ;
95
+ expect (cookbookVersion[0 ], JsonObject (tester.version.major));
96
+ expect (cookbookVersion[1 ], JsonObject (tester.version.minor));
97
+ });
98
+ });
90
99
91
- expect (response.body, 'OK' );
100
+ group ('recipes' , () {
101
+ test ('callImport' , () async {
102
+ final url = cookbook.UrlBuilder ()..url = '${tester .targetURL }/static/recipe.html' ;
103
+ final response = await tester.client.cookbook.recipes.$import ($body: url.build ());
104
+ addTearDown (() async {
105
+ closeFixture ();
106
+ await tester.client.cookbook.recipes.deleteRecipe (id: response.body.id! );
92
107
});
93
108
94
- test ('version' , () async {
95
- final response = await tester.client.cookbook.misc.version ();
96
-
97
- final cookbookVersion = response.body.cookbookVersion! ;
98
- expect (cookbookVersion[0 ], JsonObject (tester.version.major));
99
- expect (cookbookVersion[1 ], JsonObject (tester.version.minor));
100
- });
109
+ expect (response.body, isA< cookbook.Recipe > ());
101
110
});
102
111
103
- group ('recipes' , () {
104
- test ('callImport' , () async {
105
- final url = cookbook.UrlBuilder ()..url = '${tester .targetURL }/static/recipe.html' ;
106
- final response = await tester.client.cookbook.recipes.$import ($body: url.build ());
107
- addTearDown (() async {
108
- closeFixture ();
109
- await tester.client.cookbook.recipes.deleteRecipe (id: response.body.id! );
110
- });
112
+ test ('getImage' , () async {
113
+ final recipes = await tester.client.cookbook.recipes.listRecipes ();
114
+ final recipeWithoutImage = recipes.body.firstWhere ((stub) => stub.name == 'Recipe Without an image' );
115
+ final response = await tester.client.cookbook.recipes.getImage (
116
+ id: recipeWithoutImage.id,
117
+ );
111
118
112
- expect (response.body, isA< cookbook.Recipe > ());
113
- });
119
+ expect (response.body, isNotNull);
114
120
115
- test ('getImage' , () async {
116
- final recipes = await tester.client.cookbook.recipes.listRecipes ();
117
- final recipeWithoutImage = recipes.body.firstWhere ((stub) => stub.name == 'Recipe Without an image' );
118
- final response = await tester.client.cookbook.recipes.getImage (
119
- id: recipeWithoutImage.id,
120
- );
121
+ final recipeWithImage = recipes.body.firstWhere ((stub) => stub.name == "Chef John's Gazpacho" );
122
+ final response2 = await tester.client.cookbook.recipes.getImage (
123
+ id: recipeWithImage.id,
124
+ size: cookbook.GetImageSize .full,
125
+ );
121
126
122
- expect (response.body, isNotNull);
123
-
124
- final recipeWithImage = recipes.body.firstWhere ((stub) => stub.name == "Chef John's Gazpacho" );
125
- final response2 = await tester.client.cookbook.recipes.getImage (
126
- id: recipeWithImage.id,
127
- size: cookbook.GetImageSize .full,
128
- );
129
-
130
- expect (response2.body, isNotNull);
131
- });
127
+ expect (response2.body, isNotNull);
128
+ });
132
129
133
- test ('listRecipes' , () async {
134
- final response = await tester.client.cookbook.recipes.listRecipes ();
130
+ test ('listRecipes' , () async {
131
+ final response = await tester.client.cookbook.recipes.listRecipes ();
135
132
136
- expect (response.body, hasLength (19 ));
137
- });
133
+ expect (response.body, hasLength (19 ));
134
+ });
138
135
139
- test ('newRecipe and deleteRecipe' , () async {
140
- final recipe = cookbook.RecipeBuilder ()
141
- ..name = 'My super cool recipe'
142
- ..dateCreated = DateTime .utc (2023 ).toIso8601String ();
143
- final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
144
- expect (createResponse.body, isNotNull);
136
+ test ('newRecipe and deleteRecipe' , () async {
137
+ final recipe = cookbook.RecipeBuilder ()
138
+ ..name = 'My super cool recipe'
139
+ ..dateCreated = DateTime .utc (2023 ).toIso8601String ();
140
+ final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
141
+ expect (createResponse.body, isNotNull);
145
142
146
- final deleteResponse = await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
147
- expect (deleteResponse.body, equals ('Recipe ${createResponse .body } deleted successfully' ));
148
- });
143
+ final deleteResponse = await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
144
+ expect (deleteResponse.body, equals ('Recipe ${createResponse .body } deleted successfully' ));
145
+ });
149
146
150
- test ('recipeDetails' , () async {
151
- final recipes = await tester.client.cookbook.recipes.listRecipes ();
147
+ test ('recipeDetails' , () async {
148
+ final recipes = await tester.client.cookbook.recipes.listRecipes ();
152
149
153
- for (final recipe in recipes.body) {
154
- final response = await tester.client.cookbook.recipes.recipeDetails (
155
- id: recipe.id,
156
- );
150
+ for (final recipe in recipes.body) {
151
+ final response = await tester.client.cookbook.recipes.recipeDetails (
152
+ id: recipe.id,
153
+ );
157
154
158
- expect (response.body, isNotNull);
159
- }
160
- });
155
+ expect (response.body, isNotNull);
156
+ }
157
+ });
161
158
162
- test ('search' , () async {
163
- final response = await tester.client.cookbook.recipes.search (query: 'Vegan' );
159
+ test ('search' , () async {
160
+ final response = await tester.client.cookbook.recipes.search (query: 'Vegan' );
164
161
165
- expect (response.body, hasLength (2 ));
166
- });
162
+ expect (response.body, hasLength (2 ));
163
+ });
167
164
168
- test ('updateRecipe' , () async {
169
- final recipe = cookbook.RecipeBuilder ()
170
- ..name = 'My super cool recipe'
171
- ..dateCreated = DateTime .utc (2023 ).toIso8601String ();
172
- final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
173
- addTearDown (() async {
174
- closeFixture ();
175
- await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
176
- });
177
- expect (createResponse.body, isNotNull);
178
-
179
- recipe
180
- ..id = createResponse.body.toString ()
181
- ..name = 'My updated super cool recipe' ;
182
- final updateResponse = await tester.client.cookbook.recipes
183
- .updateRecipe (id: createResponse.body.toString (), $body: recipe.build ());
184
- expect (updateResponse.body, isNotNull);
185
- });
165
+ test ('updateRecipe' , () async {
166
+ final recipe = cookbook.RecipeBuilder ()
167
+ ..name = 'My super cool recipe'
168
+ ..dateCreated = DateTime .utc (2023 ).toIso8601String ();
169
+ final createResponse = await tester.client.cookbook.recipes.newRecipe ($body: recipe.build ());
170
+ addTearDown (() async {
171
+ closeFixture ();
172
+ await tester.client.cookbook.recipes.deleteRecipe (id: createResponse.body.toString ());
173
+ });
174
+ expect (createResponse.body, isNotNull);
175
+
176
+ recipe
177
+ ..id = createResponse.body.toString ()
178
+ ..name = 'My updated super cool recipe' ;
179
+ final updateResponse = await tester.client.cookbook.recipes
180
+ .updateRecipe (id: createResponse.body.toString (), $body: recipe.build ());
181
+ expect (updateResponse.body, isNotNull);
186
182
});
183
+ });
187
184
188
- group ('tags' , () {
189
- test ('listKeywords' , () async {
190
- final response = await tester.client.cookbook.tags.listKeywords ();
185
+ group ('tags' , () {
186
+ test ('listKeywords' , () async {
187
+ final response = await tester.client.cookbook.tags.listKeywords ();
191
188
192
- expect (response.body, hasLength (16 ));
193
- });
189
+ expect (response.body, hasLength (16 ));
190
+ });
194
191
195
- test ('recipesWithKeyword' , () async {
196
- final response = await tester.client.cookbook.tags.recipesWithKeyword (keywords: 'Desserts' );
192
+ test ('recipesWithKeyword' , () async {
193
+ final response = await tester.client.cookbook.tags.recipesWithKeyword (keywords: 'Desserts' );
197
194
198
- expect (response.body, hasLength (0 ));
199
- });
195
+ expect (response.body, hasLength (0 ));
200
196
});
201
- },
202
- retry: retryCount,
203
- timeout: timeout,
204
- );
197
+ });
198
+ });
205
199
}
0 commit comments