mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
tests for http options
This commit is contained in:
@@ -77,3 +77,21 @@ final Map<String, dynamic> historyRequestModelJson2 = {
|
|||||||
"httpRequestModel": httpRequestModelPost10Json,
|
"httpRequestModel": httpRequestModelPost10Json,
|
||||||
"httpResponseModel": responseModelJson,
|
"httpResponseModel": responseModelJson,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Basic History Meta model 1
|
||||||
|
final historyMetaModel3 = HistoryMetaModel(
|
||||||
|
historyId: 'historyId3',
|
||||||
|
requestId: 'requestId3',
|
||||||
|
apiType: APIType.rest,
|
||||||
|
url: 'https://reqbin.com/echo/options',
|
||||||
|
method: HTTPVerb.options,
|
||||||
|
timeStamp: DateTime(2024, 1, 1),
|
||||||
|
responseStatus: 200,
|
||||||
|
);
|
||||||
|
|
||||||
|
final historyRequestModel3 = HistoryRequestModel(
|
||||||
|
historyId: 'historyId3',
|
||||||
|
metaData: historyMetaModel3,
|
||||||
|
httpRequestModel: httpRequestModelOptions1,
|
||||||
|
httpResponseModel: responseModel,
|
||||||
|
);
|
||||||
|
|||||||
@@ -75,5 +75,13 @@ void main() {
|
|||||||
expect(historyRequestModel.httpRequestModel, httpRequestModelGet4);
|
expect(historyRequestModel.httpRequestModel, httpRequestModelGet4);
|
||||||
expect(historyRequestModel.httpResponseModel, responseModel);
|
expect(historyRequestModel.httpResponseModel, responseModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Testing HistoryRequestModel getters", () {
|
||||||
|
var historyRequestModel = historyRequestModel3;
|
||||||
|
expect(historyRequestModel.historyId, 'historyId3');
|
||||||
|
expect(historyRequestModel.metaData, historyMetaModel3);
|
||||||
|
expect(historyRequestModel.httpRequestModel, httpRequestModelOptions1);
|
||||||
|
expect(historyRequestModel.httpResponseModel, responseModel);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,3 +466,9 @@ const httpRequestModelPost13 = HttpRequestModel(
|
|||||||
"text": "I LOVE Flutter"
|
"text": "I LOVE Flutter"
|
||||||
}""",
|
}""",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Basic OPTIONS request model
|
||||||
|
const httpRequestModelOptions1 = HttpRequestModel(
|
||||||
|
method: HTTPVerb.options,
|
||||||
|
url: 'https://reqbin.com/echo/options',
|
||||||
|
);
|
||||||
|
|||||||
@@ -253,3 +253,9 @@ const requestModelPost13 = RequestModel(
|
|||||||
apiType: APIType.rest,
|
apiType: APIType.rest,
|
||||||
httpRequestModel: httpRequestModelPost13,
|
httpRequestModel: httpRequestModelPost13,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const requestModelOptions1 = RequestModel(
|
||||||
|
id: 'options1',
|
||||||
|
apiType: APIType.rest,
|
||||||
|
httpRequestModel: httpRequestModelOptions1,
|
||||||
|
);
|
||||||
|
|||||||
@@ -119,4 +119,21 @@ void main() {
|
|||||||
test('Testing hashcode', () {
|
test('Testing hashcode', () {
|
||||||
expect(responseModel.hashCode, greaterThan(0));
|
expect(responseModel.hashCode, greaterThan(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Testing fromResponse for OPTIONS method', () async {
|
||||||
|
var responseRec = await sendHttpRequest(
|
||||||
|
requestModelOptions1.id,
|
||||||
|
requestModelOptions1.apiType,
|
||||||
|
requestModelOptions1.httpRequestModel!,
|
||||||
|
defaultUriScheme: kDefaultUriScheme,
|
||||||
|
noSSL: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
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?['allow']?.contains("OPTIONS"), true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user