mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Added Tests for (/lib/utils): 100% Coverage
This commit is contained in:
@@ -94,81 +94,6 @@ void main() {
|
||||
expect(formatHeaderCase(headerText2), headerText2Expected);
|
||||
});
|
||||
});
|
||||
group("Testing rowsToMap", () {
|
||||
test('Testing for null', () {
|
||||
expect(rowsToMap(null), null);
|
||||
});
|
||||
test('Testing for string KVRow values', () {
|
||||
const kvRow1 = NameValueModel(name: "code", value: "IN");
|
||||
expect(rowsToMap([kvRow1]), {"code": "IN"});
|
||||
});
|
||||
test('Testing when header is True', () {
|
||||
const kvRow2 = NameValueModel(name: "Text", value: "ABC");
|
||||
expect(rowsToMap([kvRow2], isHeader: true), {"text": "ABC"});
|
||||
});
|
||||
test('Testing when header is false and key is in upper case', () {
|
||||
const kvRow3 = <NameValueModel>[
|
||||
NameValueModel(name: "TEXT", value: "ABC"),
|
||||
NameValueModel(name: "version", value: 0.1),
|
||||
NameValueModel(name: "month", value: 4),
|
||||
];
|
||||
expect(
|
||||
rowsToMap(kvRow3), {"TEXT": "ABC", "version": "0.1", "month": "4"});
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing mapToRows", () {
|
||||
test('Testing for null', () {
|
||||
expect(mapToRows(null), null);
|
||||
});
|
||||
test('Testing with a map value', () {
|
||||
Map<String, String> value1 = {"text": "abc", "lang": "eng", "code": "1"};
|
||||
const result1Expected = <NameValueModel>[
|
||||
NameValueModel(name: "text", value: "abc"),
|
||||
NameValueModel(name: "lang", value: "eng"),
|
||||
NameValueModel(name: "code", value: "1")
|
||||
];
|
||||
expect(mapToRows(value1), result1Expected);
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing rowsToFormDataMapList", () {
|
||||
test('Testing for null', () {
|
||||
expect(rowsToFormDataMapList(null), null);
|
||||
});
|
||||
test('Testing with a map value', () {
|
||||
const input = <FormDataModel>[
|
||||
FormDataModel(name: "text", value: "abc", type: FormDataType.file),
|
||||
FormDataModel(name: "lang", value: "eng", type: FormDataType.file),
|
||||
FormDataModel(name: "code", value: "1", type: FormDataType.text)
|
||||
];
|
||||
const expectedResult = [
|
||||
{"name": "text", "value": "abc", "type": "file"},
|
||||
{"name": "lang", "value": "eng", "type": "file"},
|
||||
{"name": "code", "value": "1", "type": "text"}
|
||||
];
|
||||
expect(rowsToFormDataMapList(input), expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing mapListToFormDataModelRows", () {
|
||||
test('Testing for null', () {
|
||||
expect(mapListToFormDataModelRows(null), null);
|
||||
});
|
||||
test('Testing with a map value', () {
|
||||
const input = [
|
||||
{"name": "text", "value": "abc", "type": "file"},
|
||||
{"name": "lang", "value": "eng", "type": "file"},
|
||||
{"name": "code", "value": "1", "type": "text"}
|
||||
];
|
||||
const expectedResult = <FormDataModel>[
|
||||
FormDataModel(name: "text", value: "abc", type: FormDataType.file),
|
||||
FormDataModel(name: "lang", value: "eng", type: FormDataType.file),
|
||||
FormDataModel(name: "code", value: "1", type: FormDataType.text)
|
||||
];
|
||||
expect(mapListToFormDataModelRows(input), expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing getFormDataType", () {
|
||||
test('Testing for null', () {
|
||||
@@ -240,41 +165,6 @@ Easily manipulate and play around with request inputs like headers, query parame
|
||||
});
|
||||
});
|
||||
|
||||
group("Test getEnabledRows", () {
|
||||
test('Testing for null', () {
|
||||
expect(getEnabledRows(null, null), null);
|
||||
});
|
||||
test('Testing for empty list', () {
|
||||
expect(getEnabledRows([], []), []);
|
||||
});
|
||||
const kvRow1 = NameValueModel(name: "code", value: "IN");
|
||||
const kvRow2 = NameValueModel(name: "lang", value: "eng");
|
||||
const kvRow3 = NameValueModel(name: "version", value: 0.1);
|
||||
const kvRow4 = NameValueModel(name: "month", value: 4);
|
||||
test('Testing with isRowEnabledList null', () {
|
||||
expect(getEnabledRows([kvRow1, kvRow2, kvRow3, kvRow4], null),
|
||||
[kvRow1, kvRow2, kvRow3, kvRow4]);
|
||||
});
|
||||
test('Testing for list with all enabled', () {
|
||||
expect(
|
||||
getEnabledRows(
|
||||
[kvRow1, kvRow2, kvRow3, kvRow4], [true, true, true, true]),
|
||||
[kvRow1, kvRow2, kvRow3, kvRow4]);
|
||||
});
|
||||
test('Testing for list with all disabled', () {
|
||||
expect(
|
||||
getEnabledRows(
|
||||
[kvRow1, kvRow2, kvRow3, kvRow4], [false, false, false, false]),
|
||||
[]);
|
||||
});
|
||||
test('Testing for list with some disabled', () {
|
||||
expect(
|
||||
getEnabledRows(
|
||||
[kvRow1, kvRow2, kvRow3, kvRow4], [true, false, true, false]),
|
||||
[kvRow1, kvRow3]);
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing audioPosition function", () {
|
||||
test('Testing using dur1', () {
|
||||
Duration dur1 = const Duration(minutes: 1, seconds: 3);
|
||||
|
||||
Reference in New Issue
Block a user