diff --git a/lib/codegen/rust/ureq.dart b/lib/codegen/rust/ureq.dart index b9b70e23..6137f4fc 100644 --- a/lib/codegen/rust/ureq.dart +++ b/lib/codegen/rust/ureq.dart @@ -126,8 +126,7 @@ multipart/form-data; boundary={{boundary}}'''; Uri? uri = rec.$1; var method = requestModel.method; var requestBody = requestModel.body; - if (requestModel.bodyContentType == ContentType.json && - requestBody?.isNotEmpty == true) { + if (requestModel.bodyContentType == ContentType.json && requestBody?.isNotEmpty == true){ result += kJsonImport; } if (uri != null) { @@ -137,7 +136,8 @@ multipart/form-data; boundary={{boundary}}'''; 'isFormDataRequest': requestModel.hasFormData, "method": requestModel.method.name.toLowerCase() }); - + + if (kMethodsWithBody.contains(method) && requestBody != null) { var contentLength = utf8.encode(requestBody).length; if (contentLength > 0) { diff --git a/lib/codegen/swift/urlsession.dart b/lib/codegen/swift/urlsession.dart index 864706fd..015d19af 100644 --- a/lib/codegen/swift/urlsession.dart +++ b/lib/codegen/swift/urlsession.dart @@ -96,22 +96,22 @@ task.resume() semaphore.wait() """; + String? getCode(HttpRequestModel requestModel) { try { String result = kTemplateStart; - var rec = - getValidRequestUri(requestModel.url, requestModel.enabledParams); + var rec = getValidRequestUri(requestModel.url, requestModel.enabledParams); Uri? uri = rec.$1; if (requestModel.hasFormData) { result += kTemplateFormDataImport; - + var formDataList = requestModel.formDataMapList.map((param) { if (param['type'] == 'file') { final filePath = param['value'] as String; final fileName = path.basename(filePath); - final fileExtension = + final fileExtension = path.extension(fileName).toLowerCase().replaceFirst('.', ''); return { 'type': 'file', @@ -133,16 +133,20 @@ semaphore.wait() result += templateFormData.render({ "formData": formDataList, }); - } + } // Handle JSON data else if (requestModel.hasJsonData) { var templateJsonData = jj.Template(kTemplateJsonData); - result += templateJsonData.render({"jsonData": requestModel.body!}); - } + result += templateJsonData.render({ + "jsonData": requestModel.body! + }); + } // Handle text data else if (requestModel.hasTextData) { var templateTextData = jj.Template(kTemplateTextData); - result += templateTextData.render({"textData": requestModel.body!}); + result += templateTextData.render({ + "textData": requestModel.body! + }); } var templateRequest = jj.Template(kTemplateRequest); @@ -153,11 +157,11 @@ semaphore.wait() var headers = requestModel.enabledHeadersMap; if (requestModel.hasFormData) { - headers['Content-Type'] = + headers['Content-Type'] = "multipart/form-data; boundary=\\(boundary.stringValue)"; - } else if (requestModel.hasJsonData || requestModel.hasTextData) { + } else if(requestModel.hasJsonData||requestModel.hasTextData){ headers['Content-Type'] = 'application/json'; - } + } if (headers.isNotEmpty) { var templateHeader = jj.Template(kTemplateHeaders); diff --git a/lib/consts.dart b/lib/consts.dart index 12084c2f..628598e4 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/lib/models/history_meta_model.dart b/lib/models/history_meta_model.dart index a2f01899..c0226086 100644 --- a/lib/models/history_meta_model.dart +++ b/lib/models/history_meta_model.dart @@ -1,5 +1,7 @@ import 'package:apidash_core/apidash_core.dart'; + part 'history_meta_model.freezed.dart'; + part 'history_meta_model.g.dart'; @freezed diff --git a/lib/models/history_request_model.dart b/lib/models/history_request_model.dart index ace0ece7..a895e945 100644 --- a/lib/models/history_request_model.dart +++ b/lib/models/history_request_model.dart @@ -1,7 +1,8 @@ import 'package:apidash_core/apidash_core.dart'; import 'models.dart'; -import 'package:apidash_core/apidash_core.dart'; + part 'history_request_model.freezed.dart'; + part 'history_request_model.g.dart'; @freezed diff --git a/lib/models/request_model.dart b/lib/models/request_model.dart index db0809c4..bb9eefae 100644 --- a/lib/models/request_model.dart +++ b/lib/models/request_model.dart @@ -1,5 +1,7 @@ import 'package:apidash_core/apidash_core.dart'; + part 'request_model.freezed.dart'; + part 'request_model.g.dart'; @freezed diff --git a/packages/better_networking/lib/extensions/map_extensions.dart b/packages/better_networking/lib/extensions/map_extensions.dart index bfafbb15..3c1b3063 100644 --- a/packages/better_networking/lib/extensions/map_extensions.dart +++ b/packages/better_networking/lib/extensions/map_extensions.dart @@ -2,11 +2,9 @@ import 'dart:io'; extension MapExtension on Map { bool hasKeyContentType() { - return keys.any( - (k) => (k is String) - ? k.toLowerCase() == HttpHeaders.contentTypeHeader - : false, - ); + return keys.any((k) => (k is String) + ? k.toLowerCase() == HttpHeaders.contentTypeHeader + : false); } String? getKeyContentType() { @@ -15,11 +13,9 @@ extension MapExtension on Map { } bool present = hasKeyContentType(); if (present) { - return keys.firstWhere( - (e) => (e is String) - ? e.toLowerCase() == HttpHeaders.contentTypeHeader - : false, - ); + return keys.firstWhere((e) => (e is String) + ? e.toLowerCase() == HttpHeaders.contentTypeHeader + : false); } return null; } @@ -30,8 +26,7 @@ extension MapExtension on Map { Map removeKeyContentType() { removeWhere( - (key, value) => key.toLowerCase() == HttpHeaders.contentTypeHeader, - ); + (key, value) => key.toLowerCase() == HttpHeaders.contentTypeHeader); return this; } -} +} \ No newline at end of file diff --git a/packages/better_networking/lib/models/http_response_model.dart b/packages/better_networking/lib/models/http_response_model.dart index b3effc76..316e5b79 100644 --- a/packages/better_networking/lib/models/http_response_model.dart +++ b/packages/better_networking/lib/models/http_response_model.dart @@ -44,7 +44,10 @@ class DurationConverter implements JsonConverter { class HttpResponseModel with _$HttpResponseModel { const HttpResponseModel._(); - @JsonSerializable(explicitToJson: true, anyMap: true) + @JsonSerializable( + explicitToJson: true, + anyMap: true, + ) const factory HttpResponseModel({ int? statusCode, Map? headers, @@ -62,9 +65,9 @@ class HttpResponseModel with _$HttpResponseModel { MediaType? get mediaType => getMediaTypeFromHeaders(headers); HttpResponseModel fromResponse({required Response response, Duration? time}) { - final responseHeaders = mergeMaps({ - HttpHeaders.contentLengthHeader: response.contentLength.toString(), - }, response.headers); + final responseHeaders = mergeMaps( + {HttpHeaders.contentLengthHeader: response.contentLength.toString()}, + response.headers); MediaType? mediaType = getMediaTypeFromHeaders(responseHeaders); final body = (mediaType?.subtype == kSubTypeJson) ? utf8.decode(response.bodyBytes) diff --git a/packages/better_networking/lib/utils/http_request_utils.dart b/packages/better_networking/lib/utils/http_request_utils.dart index c175733a..df842232 100644 --- a/packages/better_networking/lib/utils/http_request_utils.dart +++ b/packages/better_networking/lib/utils/http_request_utils.dart @@ -1,7 +1,5 @@ -import 'package:better_networking/consts.dart'; -import 'package:seed/seed.dart'; -import '../models/models.dart'; -import 'graphql_utils.dart'; + +import 'package:better_networking/better_networking.dart'; import 'package:json5/json5.dart' as json5; Map? rowsToMap( @@ -24,7 +22,9 @@ Map? rowsToMap( return finalMap; } -List? mapToRows(Map? kvMap) { +List? mapToRows( + Map? kvMap, +) { if (kvMap == null) { return null; } @@ -35,45 +35,47 @@ List? mapToRows(Map? kvMap) { return finalRows; } -List>? rowsToFormDataMapList(List? kvRows) { +List>? rowsToFormDataMapList( + List? kvRows, +) { if (kvRows == null) { return null; } List> finalMap = kvRows - .map( - (FormDataModel formData) => - (formData.name.trim().isEmpty && formData.value.trim().isEmpty) - ? null - : { - "name": formData.name, - "value": formData.value, - "type": formData.type.name, - }, - ) + .map((FormDataModel formData) => + (formData.name.trim().isEmpty && formData.value.trim().isEmpty) + ? null + : { + "name": formData.name, + "value": formData.value, + "type": formData.type.name, + }) .nonNulls .toList(); return finalMap; } -List? mapListToFormDataModelRows(List? kvMap) { +List? mapListToFormDataModelRows( + List? kvMap, +) { if (kvMap == null) { return null; } - List finalRows = kvMap.map((formData) { - return FormDataModel( - name: formData["name"], - value: formData["value"], - type: getFormDataType(formData["type"]), - ); - }).toList(); + List finalRows = kvMap.map( + (formData) { + return FormDataModel( + name: formData["name"], + value: formData["value"], + type: getFormDataType(formData["type"]), + ); + }, + ).toList(); return finalRows; } FormDataType getFormDataType(String? type) { - return FormDataType.values.firstWhere( - (element) => element.name == type, - orElse: () => FormDataType.text, - ); + return FormDataType.values.firstWhere((element) => element.name == type, + orElse: () => FormDataType.text); } List? getEnabledRows( @@ -83,9 +85,8 @@ List? getEnabledRows( if (rows == null || isRowEnabledList == null) { return rows; } - List finalRows = rows - .where((element) => isRowEnabledList[rows.indexOf(element)]) - .toList(); + List finalRows = + rows.where((element) => isRowEnabledList[rows.indexOf(element)]).toList(); return finalRows == [] ? null : finalRows; } @@ -108,4 +109,4 @@ String? removeJsonComments(String? json) { } catch (e) { return json; } -} +} \ No newline at end of file diff --git a/packages/better_networking/lib/utils/uri_utils.dart b/packages/better_networking/lib/utils/uri_utils.dart index 9dbf922e..a330e582 100644 --- a/packages/better_networking/lib/utils/uri_utils.dart +++ b/packages/better_networking/lib/utils/uri_utils.dart @@ -23,10 +23,8 @@ String stripUrlParams(String url) { } (Uri?, String?) getValidRequestUri( - String? url, - List? requestParams, { - SupportedUriSchemes defaultUriScheme = kDefaultUriScheme, -}) { + String? url, List? requestParams, + {SupportedUriSchemes defaultUriScheme = kDefaultUriScheme}) { url = url?.trim(); if (url == null || url == "") { return (null, "URL is missing!"); diff --git a/packages/better_networking/test/extensions/map_extensions_test.dart b/packages/better_networking/test/extensions/map_extensions_test.dart index 7de036c0..5082c906 100644 --- a/packages/better_networking/test/extensions/map_extensions_test.dart +++ b/packages/better_networking/test/extensions/map_extensions_test.dart @@ -112,16 +112,18 @@ void main() { group("Testing ?.getValueContentType() function", () { test('Testing ?.getValueContentType() for header1', () { - Map header1 = {"content-type": "application/json"}; + Map header1 = { + "content-type": "application/json", + }; String contentType1Expected = "application/json"; expect(header1.getValueContentType(), contentType1Expected); }); - test( - 'Testing ?.getValueContentType() when header keys are in header case', - () { - Map header2 = {"Content-Type": "application/json"}; - expect(header2.getValueContentType(), "application/json"); - }, - ); + test('Testing ?.getValueContentType() when header keys are in header case', + () { + Map header2 = { + "Content-Type": "application/json", + }; + expect(header2.getValueContentType(), "application/json"); + }); }); } diff --git a/packages/better_networking/test/utils/http_response_utils.dart b/packages/better_networking/test/utils/http_response_utils.dart index 4b14d52a..875c576f 100644 --- a/packages/better_networking/test/utils/http_response_utils.dart +++ b/packages/better_networking/test/utils/http_response_utils.dart @@ -1,7 +1,6 @@ -import 'package:better_networking/utils/content_type_utils.dart'; -import 'package:better_networking/utils/http_response_utils.dart'; + +import 'package:better_networking/better_networking.dart'; import 'package:better_networking/utils/string_utils.dart'; -import 'package:http_parser/http_parser.dart'; import 'package:test/test.dart'; void main() { @@ -9,10 +8,8 @@ void main() { test('Testing getMediaTypeFromContentType for json type', () { String contentType1 = "application/json"; MediaType mediaType1Expected = MediaType("application", "json"); - expect( - getMediaTypeFromContentType(contentType1).toString(), - mediaType1Expected.toString(), - ); + expect(getMediaTypeFromContentType(contentType1).toString(), + mediaType1Expected.toString()); }); test('Testing getMediaTypeFromContentType for null', () { expect(getMediaTypeFromContentType(null), null); @@ -20,10 +17,8 @@ void main() { test('Testing getMediaTypeFromContentType for image svg+xml type', () { String contentType3 = "image/svg+xml"; MediaType mediaType3Expected = MediaType("image", "svg+xml"); - expect( - getMediaTypeFromContentType(contentType3).toString(), - mediaType3Expected.toString(), - ); + expect(getMediaTypeFromContentType(contentType3).toString(), + mediaType3Expected.toString()); }); test('Testing getMediaTypeFromContentType for incorrect content type', () { String contentType4 = "text/html : charset=utf-8"; @@ -31,13 +26,10 @@ void main() { }); test('Testing getMediaTypeFromContentType for text/css type', () { String contentType5 = "text/css; charset=utf-8"; - MediaType mediaType5Expected = MediaType("text", "css", { - "charset": "utf-8", - }); - expect( - getMediaTypeFromContentType(contentType5).toString(), - mediaType5Expected.toString(), - ); + MediaType mediaType5Expected = + MediaType("text", "css", {"charset": "utf-8"}); + expect(getMediaTypeFromContentType(contentType5).toString(), + mediaType5Expected.toString()); }); test('Testing getMediaTypeFromContentType for incorrect with double ;', () { String contentType6 = @@ -62,13 +54,11 @@ void main() { Map header1 = { "content-length": "4506", "cache-control": "private", - "content-type": "application/json", + "content-type": "application/json" }; MediaType mediaType1Expected = MediaType("application", "json"); - expect( - getMediaTypeFromHeaders(header1).toString(), - mediaType1Expected.toString(), - ); + expect(getMediaTypeFromHeaders(header1).toString(), + mediaType1Expected.toString()); }); test('Testing getMediaTypeFromHeaders for null header', () { expect(getMediaTypeFromHeaders(null), null); @@ -82,26 +72,22 @@ void main() { expect(getMediaTypeFromHeaders(header3), null); }); test( - 'Testing getMediaTypeFromHeaders for erroneous header value - missing type', - () { - Map header4 = {"content-type": "/json"}; - expect(getMediaTypeFromHeaders(header4), null); - }, - ); + 'Testing getMediaTypeFromHeaders for erroneous header value - missing type', + () { + Map header4 = {"content-type": "/json"}; + expect(getMediaTypeFromHeaders(header4), null); + }); test( - 'Testing getMediaTypeFromHeaders for erroneous header value - missing subtype', - () { - Map header5 = {"content-type": "application"}; - expect(getMediaTypeFromHeaders(header5), null); - }, - ); + 'Testing getMediaTypeFromHeaders for erroneous header value - missing subtype', + () { + Map header5 = {"content-type": "application"}; + expect(getMediaTypeFromHeaders(header5), null); + }); test('Testing getMediaTypeFromHeaders for header6', () { Map header6 = {"content-type": "image/svg+xml"}; MediaType mediaType6Expected = MediaType("image", "svg+xml"); - expect( - getMediaTypeFromHeaders(header6).toString(), - mediaType6Expected.toString(), - ); + expect(getMediaTypeFromHeaders(header6).toString(), + mediaType6Expected.toString()); }); }); @@ -172,13 +158,12 @@ void main() { expect(formatBody(body5, mediaTypeHtml), null); }); test( - 'Testing formatBody for html subtype values with random values within limit', - () { - String body6 = - '''${RandomStringGenerator.getRandomStringLines(100, 190)}'''; - expect(formatBody(body6, mediaTypeHtml), body6); - }, - ); + 'Testing formatBody for html subtype values with random values within limit', + () { + String body6 = + '''${RandomStringGenerator.getRandomStringLines(100, 190)}'''; + expect(formatBody(body6, mediaTypeHtml), body6); + }); }); }); -} +} \ No newline at end of file diff --git a/packages/better_networking/test/utils/uri_utils_test.dart b/packages/better_networking/test/utils/uri_utils_test.dart index 6d68d9e3..dc149072 100644 --- a/packages/better_networking/test/utils/uri_utils_test.dart +++ b/packages/better_networking/test/utils/uri_utils_test.dart @@ -1,16 +1,15 @@ -import 'package:better_networking/utils/uri_utils.dart'; -import 'package:seed/seed.dart'; + +import 'package:better_networking/better_networking.dart'; import 'package:test/test.dart'; void main() { group("Testing getUriScheme", () { test('Testing getUriScheme for https', () { Uri uri1 = Uri( - scheme: 'https', - host: 'dart.dev', - path: 'guides/libraries/library-tour', - fragment: 'numbers', - ); + scheme: 'https', + host: 'dart.dev', + path: 'guides/libraries/library-tour', + fragment: 'numbers'); String uriScheme1Expected = 'https'; expect(getUriScheme(uri1), (uriScheme1Expected, true)); }); @@ -30,14 +29,12 @@ void main() { }); group("Testing getValidRequestUri", () { - test( - 'Testing getValidRequestUri with localhost URL without port or path', - () { - String url1 = "localhost"; - Uri uri1Expected = Uri(scheme: 'http', host: 'localhost'); - expect(getValidRequestUri(url1, []), (uri1Expected, null)); - }, - ); + test('Testing getValidRequestUri with localhost URL without port or path', + () { + String url1 = "localhost"; + Uri uri1Expected = Uri(scheme: 'http', host: 'localhost'); + expect(getValidRequestUri(url1, []), (uri1Expected, null)); + }); test('Testing getValidRequestUri with localhost URL with port', () { String url1 = "localhost:8080"; @@ -45,19 +42,13 @@ void main() { expect(getValidRequestUri(url1, []), (uri1Expected, null)); }); - test( - 'Testing getValidRequestUri with localhost URL with port and path', - () { - String url1 = "localhost:8080/hello"; - Uri uri1Expected = Uri( - scheme: 'http', - host: 'localhost', - port: 8080, - path: '/hello', - ); - expect(getValidRequestUri(url1, []), (uri1Expected, null)); - }, - ); + test('Testing getValidRequestUri with localhost URL with port and path', + () { + String url1 = "localhost:8080/hello"; + Uri uri1Expected = + Uri(scheme: 'http', host: 'localhost', port: 8080, path: '/hello'); + expect(getValidRequestUri(url1, []), (uri1Expected, null)); + }); test('Testing getValidRequestUri with localhost URL with http prefix', () { String url1 = "http://localhost:3080"; @@ -85,12 +76,8 @@ void main() { test('Testing getValidRequestUri with IP URL with port and path', () { String url1 = "8.8.8.8:8080/hello"; - Uri uri1Expected = Uri( - scheme: 'http', - host: '8.8.8.8', - port: 8080, - path: '/hello', - ); + Uri uri1Expected = + Uri(scheme: 'http', host: '8.8.8.8', port: 8080, path: '/hello'); expect(getValidRequestUri(url1, []), (uri1Expected, null)); }); @@ -110,11 +97,10 @@ void main() { String url1 = "https://api.apidash.dev/country/data"; const kvRow1 = NameValueModel(name: "code", value: "US"); Uri uri1Expected = Uri( - scheme: 'https', - host: 'api.apidash.dev', - path: 'country/data', - queryParameters: {'code': 'US'}, - ); + scheme: 'https', + host: 'api.apidash.dev', + path: 'country/data', + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url1, [kvRow1]), (uri1Expected, null)); }); test('Testing getValidRequestUri for null url value', () { @@ -129,52 +115,44 @@ void main() { String url4 = "api.apidash.dev/country/data"; const kvRow4 = NameValueModel(name: "code", value: "US"); Uri uri4Expected = Uri( - scheme: 'https', - host: 'api.apidash.dev', - path: 'country/data', - queryParameters: {'code': 'US'}, - ); + scheme: 'https', + host: 'api.apidash.dev', + path: 'country/data', + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url4, [kvRow4]), (uri4Expected, null)); }); test('Testing getValidRequestUri when url has fragment', () { String url5 = "https://dart.dev/guides/libraries/library-tour#numbers"; Uri uri5Expected = Uri( - scheme: 'https', - host: 'dart.dev', - path: '/guides/libraries/library-tour', - ); + scheme: 'https', + host: 'dart.dev', + path: '/guides/libraries/library-tour'); expect(getValidRequestUri(url5, null), (uri5Expected, null)); }); test('Testing getValidRequestUri when uri scheme is not supported', () { String url5 = "mailto:someone@example.com"; - expect(getValidRequestUri(url5, null), ( - null, - "Unsupported URL Scheme (mailto)", - )); + expect(getValidRequestUri(url5, null), + (null, "Unsupported URL Scheme (mailto)")); }); - test( - 'Testing getValidRequestUri when query params in both url and kvrow', - () { - String url6 = "api.apidash.dev/country/data?code=IND"; - const kvRow6 = NameValueModel(name: "code", value: "US"); - Uri uri6Expected = Uri( + test('Testing getValidRequestUri when query params in both url and kvrow', + () { + String url6 = "api.apidash.dev/country/data?code=IND"; + const kvRow6 = NameValueModel(name: "code", value: "US"); + Uri uri6Expected = Uri( scheme: 'https', host: 'api.apidash.dev', path: 'country/data', - queryParameters: {'code': 'US'}, - ); - expect(getValidRequestUri(url6, [kvRow6]), (uri6Expected, null)); - }, - ); + queryParameters: {'code': 'US'}); + expect(getValidRequestUri(url6, [kvRow6]), (uri6Expected, null)); + }); test('Testing getValidRequestUri when kvrow is null', () { String url7 = "api.apidash.dev/country/data?code=US"; Uri uri7Expected = Uri( - scheme: 'https', - host: 'api.apidash.dev', - path: 'country/data', - queryParameters: {'code': 'US'}, - ); + scheme: 'https', + host: 'api.apidash.dev', + path: 'country/data', + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url7, null), (uri7Expected, null)); }); }); -} +} \ No newline at end of file diff --git a/test/codegen/swift_alamofire_codegen_test.dart b/test/codegen/swift_alamofire_codegen_test.dart index 9925b13b..c5c5f003 100644 --- a/test/codegen/swift_alamofire_codegen_test.dart +++ b/test/codegen/swift_alamofire_codegen_test.dart @@ -395,6 +395,7 @@ dispatchMain()"""; expectedCode); }); }, + ); group( @@ -464,6 +465,7 @@ dispatchMain()"""; expectedCode); }); }, + ); group( @@ -648,6 +650,7 @@ dispatchMain()"""; expectedCode); }); + test('POST 6', () { const expectedCode = r""" import Foundation @@ -686,6 +689,9 @@ dispatchMain()"""; expectedCode); }); + + + test('POST 7', () { const expectedCode = r""" import Foundation @@ -794,7 +800,7 @@ dispatchMain()"""; SupportedUriSchemes.https, ), expectedCode); - }); + }); test('POST 10', () { const expectedCode = r''' import Foundation @@ -831,6 +837,7 @@ dispatchMain()'''; expectedCode); }); }, + ); group( @@ -872,6 +879,7 @@ dispatchMain()'''; expectedCode); }); }, + ); group( @@ -913,6 +921,7 @@ dispatchMain()'''; expectedCode); }); }, + ); group( @@ -986,5 +995,6 @@ dispatchMain()'''; expectedCode); }); }, + ); } diff --git a/test/models/response_model_test.dart b/test/models/response_model_test.dart index 48ec8f13..74872cdb 100644 --- a/test/models/response_model_test.dart +++ b/test/models/response_model_test.dart @@ -131,14 +131,9 @@ void main() { final responseData = responseModel.fromResponse(response: responseRec.$1!); expect(responseData.statusCode, 200); - expect(responseData.headers?['access-control-allow-methods'], - 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); - expect( - responseData.headers?['access-control-allow-methods'] - ?.contains("OPTIONS"), - true); - expect(responseData.headers?['allow'], - 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); + expect(responseData.headers?['access-control-allow-methods'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); + expect(responseData.headers?['access-control-allow-methods']?.contains("OPTIONS"), true); + expect(responseData.headers?['allow'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS'); expect(responseData.headers?['allow']?.contains("OPTIONS"), true); }); } diff --git a/test/utils/envvar_utils_test.dart b/test/utils/envvar_utils_test.dart index cbea4c05..48fc7735 100644 --- a/test/utils/envvar_utils_test.dart +++ b/test/utils/envvar_utils_test.dart @@ -1,7 +1,6 @@ import 'package:apidash/utils/envvar_utils.dart'; import 'package:apidash/consts.dart'; import 'package:apidash_core/apidash_core.dart'; -import 'package:apidash_core/apidash_core.dart'; import 'package:test/test.dart'; const envVars = [ diff --git a/test/utils/http_utils_test.dart b/test/utils/http_utils_test.dart index bc7a7ad8..7ffc7551 100644 --- a/test/utils/http_utils_test.dart +++ b/test/utils/http_utils_test.dart @@ -1,4 +1,4 @@ -import 'package:apidash_core/apidash_core.dart'; +import 'package:apidash_core/apidash_core.dart' show MediaType; import 'package:test/test.dart'; import 'package:apidash/utils/http_utils.dart'; import 'package:apidash/consts.dart';