mirror of
https://github.com/foss42/apidash.git
synced 2025-05-30 05:21:15 +08:00
Add getValueContentType()
This commit is contained in:
@ -19,4 +19,8 @@ extension MapExtension on Map {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? getValueContentType() {
|
||||||
|
return this[getKeyContentType()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ void main() {
|
|||||||
expect(mapEx.getKeyContentType(), "Content-Type");
|
expect(mapEx.getKeyContentType(), "Content-Type");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('content-Type present should return true', () {
|
test('content-Type present', () {
|
||||||
Map<String, String> mapEx = {"Agent": "Test", "content-Type": "x"};
|
Map<String, String> mapEx = {"Agent": "Test", "content-Type": "x"};
|
||||||
expect(mapEx.getKeyContentType(), "content-Type");
|
expect(mapEx.getKeyContentType(), "content-Type");
|
||||||
});
|
});
|
||||||
@ -72,4 +72,41 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('Testing getValueContentType()', () {
|
||||||
|
test('Content-Type present', () {
|
||||||
|
Map<String, String> mapEx = {"Agent": "Test", "Content-Type": "x"};
|
||||||
|
expect(mapEx.getValueContentType(), "x");
|
||||||
|
});
|
||||||
|
|
||||||
|
test('content-Type present', () {
|
||||||
|
Map<String, String> mapEx = {"Agent": "Test", "content-Type": "x"};
|
||||||
|
expect(mapEx.getValueContentType(), "x");
|
||||||
|
});
|
||||||
|
|
||||||
|
test('empty should return null', () {
|
||||||
|
Map<String, String> mapEx = {};
|
||||||
|
expect(mapEx.getValueContentType(), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('No content-type present should return null', () {
|
||||||
|
Map<String, String> mapEx = {"Agent": "Test"};
|
||||||
|
expect(mapEx.getValueContentType(), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Different datatype should return null', () {
|
||||||
|
Map mapEx = {1: "Test"};
|
||||||
|
expect(mapEx.getValueContentType(), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Mixed datatype but should return x', () {
|
||||||
|
Map mapEx = {1: "Test", "content-type": "x"};
|
||||||
|
expect(mapEx.getValueContentType(), "x");
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple occurence should return first', () {
|
||||||
|
Map mapEx = {1: "Test", "content-Type": "y", "content-type": "x"};
|
||||||
|
expect(mapEx.getValueContentType(), "y");
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user